DCSIMG
Filtering Data Views With Query String - Cizi

Cizi

From the desktop of SharePoint girl

Filtering Data Views With Query String

A few days ago I needed to filter web part with values from a web part that is located in another page. Usually I would have done it with Query String (URL) Filter web part. Unfortunately, my client didn’t have enterprise edition and I had to think of another way to implement this. The answer was (of course) Data view! lets see how it can be done.

Create 2 pages - the first will display the web part with the values, the second will be filter by these values.

Go to your first page and create data view with the values to filter by (in this example documents types).

NewDataView

Now, make the values clickable: Click on the name of the field and choose Hyperlink in Format as… field.

ConvertToHyperlink

In the address filed chose the destination page (the second page you created – number 1 in the following picture) and add the parameters in this structure: ParmName={@Filed} in this example DocType={@Title}  (Number 2 in the following example).

For every parameter you would like to pass in the URL you will need this structure; in order to add more parameters use &. For example: DocType={@Title}&ID={@ID}. Click ok.

Hyperlonk

 

  • The display name was change – use only {@Title} (or any other filed you need) (Number 3 in the above example).
  • The value are now Hyperlinks (next picture).

AllItems-Arelink

Reattach the page, check it in and close it.

Detach the second page from its layout and insert you data view. This data view should be the one that will be filter according to the values in the first page.

Click on the small arrow next to the data view and chose filter. Under the field name chose the field that will be filter (in my example – document type); Under value chose Create new parameter…

FilterCartria

Data view parameters window will appear. Under Parameters source chose Query String, under Query String Variable enter the parameter you used in the first page as hyperlink (as shown in the following picture). In my example: DocType. You can also add default value. Click OK and then Ok.

Parmeters

You can see that now, there are no items in the web part. For your connivance you can check Show with sample data checkbox (in the Common data view tasks menu).

Reattach the page, check it in and close it.

Now, let’s go to the first page we created. Click on one of the filter values and see the result…

firstPage

(I clicked on Detailed Design and here is the result…)

secoundPage

In this example I chose to display “document type” in the data view in second page (in addition to the first page). When you’re using data view it is not necessary; But when you are using the browser web parts you have to display these fields in order to filter the web parts. 

  I find this way much easier to work with (rather than URL Filter web part) because when your working with the filter web part – every time you will edit the page in the SPD the connection will be remove automatically (unless you’re working in code mode all the time).

 

Hope this post was helpful.

Inbar.

Comments

Cizi said:

In the previous post I talked about filtering data views with URL parameters. In this post I will deal

# January 7, 2009 11:17 PM

Saranya said:

Hi,

  I followed the same steps as in ur article. But since the url is encoded in Sharepoint, while passing my querystring which assd%20bsd%20wdde, it was not filtered in my XSLT. I used contains for comparison in filtering. Any thoughts? How is it working for you with encoded characters? Please help.

# March 5, 2009 8:33 AM

... said:

Dies ist ein gro�er Ort. Ich m�chte hier noch einmal.

# March 6, 2009 11:38 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: