How to Filter based on multiple dropdowns in SPServices.SPCascadeDropdowns ?

Sep 12, 2012 at 9:43 AM
Edited Sep 12, 2012 at 11:07 AM

Hi Marc,

Thanks a lot for providing useful stuffs.

I used SPServices.SPCascadeDropdowns for filtering Countries (Parent)->Region (child)->State (sub child). I used "jquery.SPServices-0.6.2.min.js"

'State' filtering only happens based on 'Region'. But is it feasible to filter 'State' based on Region & Country? I tried using CAMQuery parameter but not able to inject dynamic value as selected in 'Country' dropdown. I tried change() function too on Child dropdown but in vain.

Below is my code where filtering doesn't happen on 'State' dropdown.
<script language="javascript" type="text/javascript">

//=======================Country(Parent) dropdown=====================
$(document).ready(function() 
{
$().SPServices.SPCascadeDropdowns(
{
relationshipList: "Regions",
relationshipListParentColumn: "Country",
relationshipListChildColumn: "Region",
parentColumn: "Country",
childColumn: "Region",
selectSingleOption: false
});
});
//====================Region (Child) Dropdown=================================
$("select[title$='Country']").ready(function() 
{
$().SPServices.SPCascadeDropdowns(
{
relationshipList: "Regions",
relationshipListParentColumn: "Region",
relationshipListChildColumn: "State",
parentColumn: "Region",
childColumn: "State",
selectSingleOption: true,
debug:true,
CAMLQuery:="<Eq><FieldRef Name='Country'/><Value Type='Text'>select[title$='Country']</Value></Eq>";
});
});
</script>

Coordinator
Sep 12, 2012 at 1:51 PM

SPCascadeDropdowns only works with one parent to one child. Others have posted their solutions to the two parent case here in the Discussions, so do some searching and you should fine some ideas.

The CAMLQuery option isn't dynamic.

M.

Sep 17, 2012 at 8:22 AM
Edited Sep 17, 2012 at 8:26 AM

Hello Marc,

You mean, it's not feasible to put dynamic value in CAMLQuery parameter ? Can you please confirm it so I can do Research based on your reply.

Coordinator
Sep 17, 2012 at 8:26 PM
Correct. The CAMLQuery is evaluated when the function is first called, not on each value change.

M.