Yes! You can add multiple filters to a List view webpart

Posted on September 18, 2009. Filed under: Data View Webparts | Tags: , , , |

Have you recently tried to apply filters from the Column Header dropdowns in any list!!!!

(After the SP2, the Column header drop downs now have the unique list field values to select and filter list items)

Try it, and see the reflected URL in the browser –

Something like this – “http://xx /test/SalesContactNewUI_Test.aspx?View={FB06F5EA-EDD3-433A-9FF4-C2CBEB88FF60}&FilterField1=Line%5Fx0020%5Fof%5Fx0020%5FBusiness&FilterValue1=Auto%20Dealer%20Commercial%20Services&FilterField2=Country&FilterValue2=Europe”

The highlighted parameters in the above URL can be utilized to apply a filter on any List view webpart.

Let’s pick the same business scenario as in my previous post .

Get your dropdowns data bounded to the look up lists, add the resp list webpart to the page and add the JavaScript method for the button click event.

Though it’s a pretty quick way of doing, we would miss the flexibility data views provide.

JavaScript –

function ApplyFilter(event)


var DropDownFilter1 = getTagFromIdentifierAndTitle(’select’,’DropDownFilter1′,”);

var Filter1 = DropDownFilter1.value;

var DropDownFilter2 = getTagFromIdentifierAndTitle(’select’,’DropDownFilter2′,”);

var Filter2 = DropDownFilter2.value;

var url = “http://” + + document.location.pathname;

              if(Filter1 != “All ” && Filter2 != “All “)


  document.location.href = url +”?View={FB06F5EA-EDD3-433A-9FF4-C2CBEB88FF60}&FilterField1=Line%5Fx0020%5Fof%5Fx0020%5FBusiness&FilterValue1=” +Filter1 +”&FilterField2=Name&FilterValue2=” +Filter2 ;


             if(Filter1 != “All ” && Filter2 == “All “)


   document.location.href = url +”?View={FB06F5EA-EDD3-433A-9FF4-C2CBEB88FF60}&FilterField1=Line%5Fx0020%5Fof%5Fx0020%5FBusiness&FilterValue1=” +Filter1 ;


             if(Filter1 == “All ” && Filter2 != “All “)


   document.location.href = url +”?View={FB06F5EA-EDD3-433A-9FF4-C2CBEB88FF60}&FilterField1=Name&FilterValue1=” +Filter2 ;


             if(Filter1 == “All ” && Filter2 == “All “)


 document.location.href = url;


 return false;



function getTagFromIdentifierAndTitle(tagName, identifier, title)


var len = identifier.length;

var tags = document.getElementsByTagName(tagName);

for (var i=0; i < tags.length; i++)


var tempString = tags[i].id;

if (tags[i].title == title && (identifier == “” || tempString.indexOf(identifier) == tempString.length – len))


return tags[i];



return null;



Make a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

2 Responses to “Yes! You can add multiple filters to a List view webpart”

RSS Feed for SharePoint Xperiments Comments RSS Feed


It is a good post…BUT i have a slightly different problem…I want to filter like “select all where Field1=’a’ or ‘b'”…
I am not to achieve this…Kindly suggest any way to achieve this…

Thanks a lot in anticipation!!!

Did u look into the other post where you can have mutiple filters using a data view webpart that approach you will need to define two data sources seperately for the same column and apply the filter. Also the customization you are looking would be more easy & flexible with sharepoint search capability.

Where's The Comment Form?


    Xperiments n Xperiences. For the Last 5 years I have been providing variuos portal solutions (SharePoint focused) to my clients and now I intend to publish few of those solutions 'Not As It Is', which might help you. – Mash


    Subscribe Via RSS

    • Subscribe with Bloglines
    • Add your feed to Newsburst from CNET
    • Subscribe in Google Reader
    • Add to My Yahoo!
    • Subscribe in NewsGator Online
    • The latest comments to all posts in RSS


Liked it here?
Why not try sites on the blogroll...

%d bloggers like this: