SPFilterDropdown and two or more filters?

Sep 9, 2011 at 2:08 PM
Edited Sep 9, 2011 at 2:33 PM

Marc,

Can you add more than one filter when using $().SPServices.SPFilterDropdown ?

e.g. CAMLQuery: "<Eq><FieldRef Name='Column1'/><Value Type='Text'>Hello</Value></Eq><Eq><FieldRef Name='Column2'/><Value Type='Text'>World</Value></Eq>"

I'm guessing from your documentation where you say the query is "And-ed" that the query is being added with an <And> to an existing "And" query somewhere behind the scenes and therefore additional filters are not possible?

Any info appreciated.

Cheers,

Andrew

-----------------------------

Just worked it out:

Yes it can be done, just add <And> to beginning of the CAMLQuery string for each additional filter and an </And> to end of each additional filter. Not needed for first filter as script adds <And> tags for you - this is what I understand to be so anyway.

e.g.

CAMLQuery: "<And><Eq><FieldRef Name='Column1'/><Value Type='Text'>Hello</Value></Eq><Eq><FieldRef Name='Column2'/><Value Type='Text'>World</Value></Eq></And>"

Pressumably this would also work:

CAMLQuery: "<And><And><Eq><FieldRef Name='Column1'/><Value Type='Text'>Hello</Value></Eq><Eq><FieldRef Name='Column2'/><Value Type='Text'>World</Value></Eq></And><Eq><FieldRef Name='Column3'/><Value Type='Text'>test</Value></Eq></And>"

 

 

 


  

 

 

Coordinator
Sep 9, 2011 at 2:46 PM
Yes, you can use a compound query, but you need to make sure that it is a valid query itself. In what you show, you aren't appropriately ANDing the two conditions.

M.
>