Filtering a list with custom links

I recently stumbled on a case where the customer wanted to filter a Document Library on Content Type with links places above the List View Web Part.

Capture 2015-10-04 at 16.17.16

When filtering the list out-of-the-box, SharePoint uses the URL, and the hash looks similiar to this:

#InplviewHash[Name of the view]=FilterField1%3D[Field]-FilterValue1%3D[Value]

The name of the view will change from page to page, so it’s hard to make that dynamic. Because of this I had to look for other ways.. and I found one.
If you use the following:

?FilterField1=[Field]&FilterValue1=[Value]
It works.. almost.. 
The problem now is that it will filter all views on the page. For this concrete customer case that’s good enough, but I’m looking for a more “complete” solution for future cases.. This solution probably involves retrieving the view name with REST.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s