Thursday, September 9, 2010

Data View Web Part Filter by URL Field

Scenario:
Lets say you have a page with multiple data (say videos) and you want to click (select) the item and open a new page with the item open (video display).

This can be done with a Data View Web Part Per Page.

Solution:
Create a data view web part in the main page that shows all data from the list, filtering and/or sorting the results, and even giving then specific layouts (I usually use Plain List style and then use xslt and css).
Here you should create a html link tag with the list item's name as text and URL (FileRef) as href.

If you're using a document library, you can use the field directly in the html,

<a href="Video.aspx?ID={@ID}" ><xsl:value-of select="@FileLeafRef" /></a>

Right now you have a page of queried items and a page that opens with an ID query string

On the view page, create a data view web part, customize it, and limit the results to one.
Here you must create a new filter, and select "Create a new parameter..." and choose "Query String" as Parameter Source. Chose ID as field and default value 1.

Now if you add to the web part's code, a video player with {@FileRef} on the URL/value/src fields, the page will actually load and play the video. You can then change autostart property and others.

Now your video page is ready to display videos clicked by the video list page.


http://www.sharepointdev.net/sharepoint--general-question-answers-discussion/using-a-parameter-to-filter-sharepoint-data-list-view-from-url-8726.shtml

No comments:

Post a Comment