Friday, February 17, 2012

Sharepoint 2010 - Filter Web Part with QueryString: an issue?

In Sharepoint 2010, when you want to filter a List Web Part with a Form Web Part, you find the simple way with querystring and XSLT query.

List web part shows 5 results per page, and we have 3 pages (so 15 items).
I search for title and I see 3 results in the first page, but I see link for the other 3 pages.
And navigating the other page, I see one more result in second page and the third is empty...!
Filter shows results for the page 1 (3 items), for the page 2 (1 item) and for the page 3 (0 items), but divided in 3 pages.

It seems filter "hides" results not matching from view, keeping pages.

I decided to use filter with querystring used by Sharepoint when you filter columns.

So the address bar shows this:

You can use javascript to retrieve value for FilterFieldN (the column name to filter, internal name!) and FilterValueN (value to use in filter).

In this way, List Web Part filtered is in the right view: if I filter my 15 items, I found olny 3, but in one page.