Monday, November 18, 2013

How to Modify the Text Filter Web Part to Allow Partial Searches (SharePoint 2010)

Hello!  If you are reading this, I am assuming that you were dramatically let down by the Text Filter Web Part as well (shakes fist at the sky).  I have no idea why Microsoft thought that only allowing exact string / text matches was a great idea for the text filter web part, but the reality is that the web part needs the flexibility to handle begins with clauses, contains, etc., and the good news is this article is how to do exactly that!

Materials Needed:

SP Designer 2010

A Web Page containing:

            The Text Filter Web Part

            Data View Web Part

By searching for this article, I am assuming that you already have a web page set up which has the text filter web part on it, so we will start the tutorial on this premise.


Starting Point:
1. Open designer

2. Open your page in advanced edit more

a. Right click and select edit in advanced mode

3. Select the split view

 
4. In the desired zone, select the data view of the list you are trying to filter off of the insert tab

a.  



 
b.  
 
 
5. Select the list you added to the page

6. Select Options

7. Select Filter

8. You will be presented with the following dialog box (select your field that you would like to filter and set your comparison to Contains or Begins With depending on your needs)

a.  



9. Select Create a new parameter

a. Rename Param1 to a name of your choosing, I will be using “FilterExample”

b. Select Query String under Parameter Source

c. Select Ok


10.Right Click Text Filter Web Part In Designer

a. Select Add Connection

b. Select Send Filter Values To

c. Select Next

d. Select Connect to a web part on this page

e. Select Next

f. Select the list you put on the page as your Target Web Part

g. Select Get Parameter From as the Target Action

h.  



i.    



j. Select Next

k. Select Finish

11.Save The Page

12.Select Yes to the dialog box

Now that you have completed the steps, the Text Filter web part should now allow partial searches of the desired field.  For this example I set my Text Filter to use contains on the Title field.  Since I defaulted my variable to not contain anything, the page should be blank to start.


After I put in the letter T and hit enter, it will filter my list and find any items containing the letter.


Cheers!
Dan

No comments:

Post a Comment