In my page I have two dropdowns, the second one depends on the choice of the first and this works, and the CAML query works, too.
How can I use $().SPServices.SPCascadeDropdowns
to run a CAML query on the parent dropdown? I just want to run the filter on it. Is there an example of how to do this? It seems like SPCascadeDropdowns
only works on the child; but I want to filter on the parent too.
But this should be the same filtering to run on just a single dropdown.
Here is what I am trying out to work on the filtering of the parent. I wasn't sure how to do this, so in my experiment I've set the parent and child to the same thing (althought it doesn't work), but I don't even know if you can use SPCascadeDropdowns
this way:
//Set up the cascading dropdowns for the parent Category dropdown
$().SPServices.SPCascadeDropdowns({
relationshipWebURL: "", //uses current site if left blank
relationshipList: "TicketCategories",
relationshipListParentColumn: "Category",
relationshipListChildColumn: "Category",
relationshipListSortColumn: "Title",
parentColumn: "Category",
childColumn: "Category",
CAMLQuery: "<Leq><FieldRef Name='" + helpdesk.catleveltitle + "'/><Value Type='Text'>" + helpdesk.catlevel + "</Value></Leq>",
CAMLQueryOptions: "<QueryOptions><IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns></QueryOptions>", // Added in 2013.01
listName: $().SPServices.SPListNameFromUrl(),
promptText: "",
simpleChild: true, // Added in v0.6.2
selectSingleOption: false, // Added in v0.6.2
matchOnId: false, // Added in v0.7.1
completefunc: null,
debug: false
});
The child dropdown works and filters perfectly based on what is selected in the parent.
//Set up the cascading dropdowns for the SubCategory dropdown
$().SPServices.SPCascadeDropdowns({
relationshipWebURL: "", //uses current site if left blank
relationshipList: "TicketSubCategories",
relationshipListParentColumn: "Category",
relationshipListChildColumn: "Title",
relationshipListSortColumn: "Title",
parentColumn: "Category",
childColumn: "SubCategory",
CAMLQuery: "<Leq><FieldRef Name='" + helpdesk.catleveltitle + "'/><Value Type='Text'>" + helpdesk.catlevel + "</Value></Leq>",
CAMLQueryOptions: "<QueryOptions><IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns></QueryOptions>", // Added in 2013.01
listName: $().SPServices.SPListNameFromUrl(),
promptText: "",
simpleChild: false, // Added in v0.6.2
selectSingleOption: false, // Added in v0.6.2
matchOnId: false, // Added in v0.7.1
completefunc: function(){
var thisSelect = "td span select[title='SubCategory']";
DisplayDependencies(thisSelect); //Do it when it loads
$(thisSelect).change( function(){
DisplayDependencies(thisSelect); //and do it when it changes
});
}, //end completefunc()
debug: false
});
I was hoping for a simple answer, but since I've been asked to show code, then now I have to explain it:
There are two lists which feed the dropdowns: Categories and SubCategories. Each of those has the name of the category as the Title
column, and it has a second column called catlevel
with a number column by which I can filter which items will show in the dropdowns based on what user group the current user is in (hence the helpdesk.catlevel
variable).
After that, the child dropdown should only show subcategories that belong to each category. (the child dropdown works perfectly).
So I'm trying to add the caml query to the parent.