SPCascadeDropdowns selectSingleOption Experience

Jan 11, 2012 at 3:50 PM
Edited Jan 11, 2012 at 3:51 PM

I recently started using your code and it is very helpful.  Thank you.  There are many discussions about this utility and I have read through some of them but not all.  I apologize if this is not a new issue. 

I have run across a case where specifying different options for the SP Filter Dropdown causes an unexpected behavior on an edit form (I'm using a CEWP on the form to place the code, with jquery-1.7.1 and SPServices-0.7.0 ).  This works:

$().SPServices.SPCascadeDropdowns({
[snip] 

 CAMLQuery: "<Eq><FieldRef Name='ContentType'/><Value Type='Text'>Visitation</Value></Eq>",
  listName: $().SPServices.SPListNameFromUrl(), 
  simpleChild: true, // Added in v0.6.2
  selectSingleOption: false, // Added in v0.6.2
  completefunc: null,
  debug: true
});

But when I switch to selectSingleOption: true, the form will not submit (error message "Value is not among the set of valid lookup values.").  Then, changing simpleChild to False makes it work again. 

Case Simple Child Select Single Result
1 True False OK
2 True True Error message
3 False True OK

The list is a complex list (>20) but the cascade cuts it to five choices and the CAML query cuts it to one choice.  Perhpas it is related to not properly updating the hidden choice value?

Thank you in advance.

 

Coordinator
Jan 13, 2012 at 2:37 PM

mjohnston9:

I've done a significant rewrite of SPCascadeDropdowns in the latest alpha. Would you mind trying it out and seeing if you still have this issue?

M.

Jan 14, 2012 at 3:03 PM

Marc,

No error for simple/single now.  Works great.  Next time I will try the alpha first.  Thank you.

You wouldn't by chance be thinking of adding this to the SPFilterDropDown (then I can easily populate with a passed query string parameter)?

Mark

 

Coordinator
Jan 17, 2012 at 1:35 PM

Mark:

Can you explain a bit more what you'd like to see in SPFilterDropdown? You can always call SPFilterDropdown and then $().SPServices.SPComplexToSimpleDropdown on the same column.

M.

Jan 20, 2012 at 1:01 PM

Marc,

If SPFilterDropDown had the selectSingleOption then I can pass a query string (code below has been edited, so there may be typos) and if there is one choice, then the user won't have to drop down to select it.  So in the code below, when a specific "Account" is known from the query string, it will be selected and shown (functionality right now is that the dropdown box is blank and the user has to select the single value), and if it is not known, then the user can select from all open accounts.  If I was more of a coder, I could probably grab your code for the cascading dropdown and toss it in the completefunc section...but I must admit that the page looks good right now and I'm working on some other parts of the website.

Thanks again,

Mark


 var queryStringVals = $().SPServices.SPGetQueryString();
 var AccountCode = queryStringVals["AccountCode"];
if (AccountCode != null)
    {
        var ACQS={
                relationshipList: "Job",
                relationshipListColumn: "Project",
                columnName: "Account",
                CAMLQuery: '"<Eq><FieldRef Name=\'AccountCode\'/><Value Type=\'Text\'>'+AccountCode+'</Value></Eq>"',
                completefunc: null,
                debug: true};
        $().SPServices.SPFilterDropdown(ACQS);
     } else
     { 
                $().SPServices.SPFilterDropdown({
                relationshipList: "Job",
                relationshipListColumn: "Project",
                columnName: "Account",
                CAMLQuery: "<Eq><FieldRef Name='Status'/><Value Type='Text'>Open</Value></Eq>",
                completefunc: null,
                debug: true
                });
}

Jan 20, 2012 at 1:47 PM

Marc,

Upon further testing the original problem is kind of back.  With the cascading dropdown set to single/simple, the single dropdown is shown and the form doesn't error out on submission, but the field is not populated in the item.   It is successful in the single/complex mode.

Mark