This project has moved and is read-only. For the latest updates, please go here.

Query Options for Cascade Drop Down

Sep 27, 2012 at 1:50 PM

Hi Marc,

First off - thanks for the amazing work you've done on this. Now, on to the request....

The Cascading dropdowns doesn't work if the relationship list has folders and items in folders, and you're wanting to match on the items in the folders.

You currently hardcode a single CAML Query Option (IncludeMandatoryColumns). Can you make it so that people can add additional query options to that? In my case, I need to add <ViewAttributes Scope='RecursiveAll' />. It wouldn't be hard to add another option, and if you want me to do it and send you back the code, I can take a first crack at it.





Sep 27, 2012 at 4:39 PM

I have run into that issue as well and it threw me for a while because I couldn't figure out why my cascading was returning such crazy results.  There is an easy method to get past it, though. Create a view that includes all items in the list with no filters and ignore folders.  Make that the default view for the list and the code will grab the entire recordset to process the cascading.  This is also true of just about any of the pre-built functions in SPServices where you need to operate starting with an entire recordset.

I'm wondering if adding the <ViewAttributes Scope='RecursiveAll' /> will be enough by itself to make the tweak to the source code.  Would that not return folders as well?  I think if you do that, you might have to also include <Neq><FieldRef Name='ContentType' /><Value Type='Text'>Folder</Value></Neq>.  I can't say that for sure but it's worth considering.

If you decide to create a flat default view for the source list (the easy route), I hope you get the results you're looking for.  If you are set on keeping a different default view that includes folders and/or filters, I would be interested in seeing what you develop to overcome your issue.  It could help me as well  :)


Sep 27, 2012 at 5:46 PM

To add on to @gkoliver's post...

The CAML should trim based on FSObjType instead of Content Type. There *could* be other content types in the list based on a folder content type which *could* be named something other than Folder. To get the results you want, you'd want to use:

<Eq><FieldRef Name='FSObjType'/><Value Type='Integer'>0</Value></Eq>

This will filter out any folders regardless of content type and will only leave items.


Sep 28, 2012 at 3:37 PM

I can't make the default view be without folders, as this list is used for other things, and the folders view is the primary use of the list. In my particular case, as long as I add the query option, I don't need to add the FSObjType where clause, because of the data that I have. But, it's good to know that should be added if necessary.

At the moment, I've hardcoded the query option in the function. But, I'll try to find time today to modify the function to accept query options as a parameter.

Sep 28, 2012 at 4:53 PM

Okay, here's what I changed to allow people to add any query options they want. I created this as a patch in WinMerge.  So, to translate, that means at line 1422 I added a line as written. Added more lines at 1492 (new lines 1494-1496). Removed the line at 1512 and replaces it with the new line as written below the removed line.


> 		var QOptions = " <IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns> ";
> 			if(opt.QueryOptions.length > 0) {
> 				QOptions += opt.QueryOptions;
> 			}
< 				CAMLQueryOptions: "<QueryOptions><IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns></QueryOptions>",
> 				CAMLQueryOptions: "<QueryOptions>" + QOptions + "</QueryOptions>",

Oct 8, 2012 at 4:24 PM


Thanks for posting your change. I'll add it as a task for the next release.

Geoff: SPCascadingDropdowns should override any settings you have on the default view. However, as Deanna has found, the function doesn't del with folders at all.


Oct 8, 2012 at 4:25 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.