Wednesday, March 7, 2007

Filtering a List by a Partial Match

On a SharePoint site I have been creating, a requirement is to display a list of Suppliers filtered by the first few letters that have been entered into a search box. One method to achieve this is using a Form Web Part and a Data View Web Part.

Add a Form Web Part to the page - in my case it is called "Search By Supplier". Next, in SharePoint Designer, add a Data View Web Part (called "Suppliers" in this case) that contains the Supplier Name column. A parameter is next added to the Data View Web Part - I have named it SupplierNameStart. This parameter will be used to tie the Web Part connection to a filter.

A new filter is added next to the Data View - the filter criteria is set so that the "Supplier Name field starts with [SupplierNameStart].

The final task is to create the web part connection. The wizard steps are as follows:
  1. Create a connection for the form web part. The "Search By Supplier" web part is to Provide Form Values To another part.
  2. The web part needs to Connect to Another Web Part on this Page
  3. Select the Suppliers web part as the target, and the target action to be Get Parameters From
  4. Choose columns - The column in the "Search By Supplier" web part is the text box name (in the HTML source of the Form Web Part). This column should be associated with the input of "SupplierNameStart" to the Supplier Web Part (i.e. the parameter).
And thus the supplier list is filtered by the letters entered into the form (when the go button is clicked)

No comments: