SharePoint – wildcard / free text searching the List View web part

Date:May 30th, 2014 Author: Tags: , ,
Category: Filter, FilterPoint Web Part, SharePoint Development Comments:8 ;

It’s a common requirement to be able to do wildcard free text searches on SharePoint lists.

Whilst you can’t do wildcard or complex Boolean search (that’s what the search system is for) you can get close with a contains search. Thus searching for “Acme” will return “ACME Construction” and “Big ACME Rentals” but not “Rent-A-Crane”

It’s not easy though, and does require SharePoint Designer and a Filter Provider such as our FilterPoint product.

Filter Providers and Filter Consumers.

In SharePoint you have

  • Filter Providers (like FilterPoint or SharePoint Enterprises own filter web parts)
  • Filter Consumers (like the List View web part or other web parts such as our PivotPoint).

The Filter Provider sends the filter you’ve entered (e.g. “Customer” and “Acme”) but it’s entirely up to the Filter Consumer what it does with that filter.

This means that if you want to do things like Date Ranges, wildcard filtering using “Contains” operations you have to set those options on the Filter Consumer.

Our products (PivotPoint, Planner etc) have options to allow you to easily set what to do with the incoming filters, but SharePoints built in List View web part does not.

Using “Contains” filters to do free text search in FilterPoint.

We’re going to use SharePoint Designer to setup Parameters and Filters in the List View Web Part (LVWP) so we can do wildcard type filtering.

(It’s a limitation of SharePoint that you can’t do this without SharePoint Designer – sorry!)

First go to the web part page that has your list (or create a new, empty web part page and add your list to it).

In our example we’ve got a list of Customers with the customer name in the Title field.

Customers List

  • Open this page in SharePoint Designers edit view.

(Depending on what type of page this is will invoice different steps – see these tips for more help on using SharePoint Designer or the online manual for SharePoint Designer)

SharePoint Designer List Parameters

  • In the Data View Parameters window :-
    • Click New Parameter,
    • In the Name box put Customer_Search.
    • (You can use whatever name you want here but it needs to be consistent across the next few steps, also note an underscore, no spaces!)
    • Change Parameter Source to Form
    • Change Form Field to Customer_Search
    • Click OK

SharePoint Desinger - add parameter

  • Now select Filter from the Ribbon (top left of the edit page view) to open the Filter Criteria window

SharePoint Designer - filter criteria

  • Choose
    • The field name you want to filter on – in our case the customers’ names are in the Title field.
    • Set the Comparison operator to Contains (this means that searching for ACME will return “ACME Corporation “or “Big ACME rentals” etc.)
    • Set Value to be the parameter we created above – Customer_Search.
    • Click OK

We’re done with SharePoint Designer (SPD) now so you can hit save and close SPD.

Open the page you’ve been working with in the browser – notice that the list won’t be displaying any results as we’re not passing in anything to our Contains Parameter.

Edit the page and add the Filter Point web part (or another FilterProvider web part of your choosing)

FilterPoint web part added

  • Select the Web Part menu (button on top right highlighted) and then Connections > Provide Filter To > Customers (or whatever your list is called.

Connect FilterPoint to customers list

  • On the next dialog box select Get Parameters From and then Finish

Web Part Connection get parameters from

  • Right – we’ve added a Parameter and a Contains Filter to the List view and connected the FitlerPoint web part to the List View, nearly there!
  • Next open FilterPoint’s configuration toolpane

FilterPoint - edit web part

    • Select New and enter a label such as Customer
    • Set the Filter Style to “Free Text”
    • Set the Field Name to From the connected web part and choose the parameter that you set above – in our case Customer_Search.
  • Click OK and you’re finally done.

(For more info on configuring FilterPoint see the manual)

Searching for “acme” or “rent” will now return any customer that has that string in their name :-

search rent search acme

A couple of points to note :-

  • You can’t do complex searches like “acme AND rent” or “Rent*Crane” – just Contains or Begins With searches.
  • If you want to setup additional filters then once you’ve connected the web parts in “Get Parameters” mode (rather than the normal “Get Filter Values” mode) you will have to repeat the above steps to create Parameters and Filters in the List for each filter. It’s a pain but a limitation of SharePoint.
  • If you do add additional Parameters and Filters be sure to set the And/Or operator correctly – for most use cases you will want And.

#

Tags: , ,

8 Responses to “SharePoint – wildcard / free text searching the List View web part”

  1. nadeem says:

    This is a great solution – however, how does it work with a look-up list column ? as CONTAINS does not appear in the Comparison coloumn. Basically I have a master transaction list in which I have a lookup column for clients (which comes from clients lists) and I want to be able to do wild card search/filter on client name in the master list.

  2. Leah says:

    Thank you, thank you! After ages of looking for an answer, this is clear, concise and it works!

  3. Ed says:

    I am using a text filter wp and when I use it to search my list it works but not with contain items. So if I do Nick or Nicole they come up but if I do Nic nothing comes up.

    Any help is greatly appreciated.
    Thanks
    Ed

  4. Amy Jo says:

    This is a great solution! Any suggestions for applying the same idea to a metadata column?

    Thanks,
    Amy Jo

  5. nadeem says:

    Wonderful solution – but is there a way to highlight the searched keyword in the searched field ?

  6. Danut says:

    Hello. This works great, but is any way i can “clear” filter? I mean a way to show all items in the list.

  7. NeStar says:

    Thank you, it works like a charm! However, when you click on any item of the list/library, View/edit property icons from the ribbon has grayed out. Any thought?

  8. Vijender says:

    when you click on any item of the list/library, View/edit property icons from the ribbon has grayed out.Has anyone resolved this?

Leave a Reply

Anti-Spam Quiz: