Searchlike filtering of lists

When you have content in SharePoint lists or libraries you want to narrow down, you have two options: You can search and you can filter.
Search gives you the flexibility to find keywords in any part of your items columns, like in the Title, Description or in the people fields like Created By. But search rely on the Crawler and its successful schedule and the result is presented in a 'not list like' format.
Filtering is done directly on the list and therefore preserves the list look, but to filter a list you need to type the exact content of a column, not just part of it. That's because a filter by default is an Equals comparison.
With a little trick found many places on the Internet, we can get the best of search and filter to work together.
Let's say you have a list that contains information's about the books you have in your library and you want to be able to filter the books based on their content.
This is how it's done:
  1. Start by creating a new view for the purpose, I call mine FilterSearch and base it on the AllItems view.
  2. Now on the Ribbon click List and then Edit List. This will startup SharePoint Designer.
  3. Once loaded click on your View in the upper right corner. NOTE: This may require Site Collection privilege dependant on your site and the setup of your masterpage. Should you get a recurring request to logon as a different user, you need to ask your local business supporter or a SharePoint Competency person for help with this step.
  4. Now click on the (XsltListView) web part to mark it and then click on Parameters
  5. In the Data View Parameters dialog, click New Parameter and give it a name, mine is called SearchFilter. Leave all other at default and click OK.
  6. Now simply hit the Save button and close SharePoint Designer.
  7. Back at the SharePoint list, refresh your page by hitting F5, then click Site Actions, Edit Page
  8. Click Add a Web Part, choose Forms, HTML Form Web Part and click Add.
  9. You might want to Edit the Web Part and change the Title, remember to set the Chrome Type to Title Only
  10. In the Team Library Web Part dropdown menu select Connections, Get Parameters From, Search the Team Library
  11. In the Configure Connection dialog, bind together T1 and SearchFilter and click Finish.
  12. Now select to Edit Web Part in the dropdown and click on Edit the current view
  13. This is where we define which fields we want to search in, note that we select the condition Contains, that each filter is OR'ed together and the special syntax of the {SearchFilter}.
  14. First thing you might notice when you click OK is that the list now shows up as empty. Now why is that? That's because we are requesting all the items with empty or NULL in their columns and because they have content we get nothing back. I thinkJ. Luckily we can apply an almost perfect workaround.
  15. Add another Web Part, this time choose Filters, Text Filter and click Add
  16. Edit the Web Part, click Advanced Filter Options and set the Default Value to something that is most likely to exist in the columns you choose to search. Unfortunately you can't search for a space, that's ignored; I found that e is almost always found in one or more columns. Period (.) could also be an option. Set the Chrome State to Minimized and the Chrome Type to None to hide the Web Part. Now click APPLY.
  17. While still in Edit Mode, from the dropdown menu, select Connections, Send Filter values to, Team Library
  18. In the dialog change the Connection Type to Get Parameters From and click Configure.
  19. Accept the default and click Finish.
  20. We now have two Web Parts that sends parameters to our list, one of them hidden.
  21. In the Ribbon, click Page, then Stop Editing.
Now the list content is showing and we can start searching (the highlighting is by me)

If you are not getting the desired results you need to ensure that the Team Library web part is getting Parameters from both Web Parts


So, that's it, enjoy search filtering! 

Comments

Popular Posts