Tuesday, December 18, 2007

Data View Web Part - Add Link to view properties form

Well... this must be the shortest tip I evet posted, and tell you the truth - its for me more than it is for you.

Every time I add a data view web part (DVWP) using the SharePoint Designer I have to look for how to add a link to the view item properties window.

Well, in case you didnt know this - DVWP has some properties that allow to build that string dynamically according to the current list. This is only done if you add a "List View" web part, and use the SharePoint Designer option to convert it to data view (menu: convert to XSLT data view, what we call DVWP).


Well, the solution is very easy, inside a <a>tag surrounding the @Title value, just add this tokens:
href="{$URL_Display}?ID={@ID}"
and thats it!



So, now I have where to get it from when I need it :) and maybe you will find it usefull as well...

11 comments:

Anonymous said...

Hi Shai,
If you try this on dvwp (create from a list, not xslt convert to a list), you get an error of URL_Dispaly parameter (not exist).
You need to include this parameter in the parameter binding.

Shai Petel said...

It depends on how you added the DVWP.

If you drag and drop it from the folder list / data source library - you are right.

But if you add a normal list view web part and right-click->convert it to DVWP, it comes with this param added.

Adding a DVWP in other ways for current site is also not recommended because of the known-issue of saving site as template (new site DVWP will not work unless you add {} to the list ID. See: http://kwizcom.blogspot.com/2007/05/sharepoint-designer-deployment-issues.html)

Anonymous said...

Hi Shai,
I want to add a link to view properties from a data view that I am using in my search center results. I copied the XML and I am modifying the XSL from Sharepoint Designer.

The problem is that I have very basic knowledge of XSL and I am unable to use href="{$URL_Display}?ID={@ID}" because 'The variable or parameter may not be defined, or it may not be in scope.'

So What I tries is adding (tag) xsl:param name="URL_Display" /(tag) and (tag) ParameterBinding Name="URL_Display" Location="Postback;Connection;CAMLVariable" DefaultValue=""/(tag)

After that, I was able to get the following output for all rows: http://rpsp2007fe/Lists//DispForm.aspx but only in Sharepoint Designer preview. After I copy my XSL back into the search results. It just ignores URL_Display and nothing displays.

I googled my heart out to try to find an answer without any luck. Could you please help me on this? I'd be very grateful -_-

Anonymous said...

Hi Shai,

Can you please have a screen shot to show where to add this parameter as I am getting an error if I add inside the {@title}.

Thank you,
Anu

Anonymous said...

Hi Shai,

Can you please have a screen shot to show where to add this parameter as I am getting an error if I add inside the {@title}.

Thank you,
Anu

Shai Petel said...

Hi, I added a picture to the post of the XSL with the use of this property.

Note: this will only work if you convert a normal SPListView web part into a DVWP! Otherwise you will have to create this parameter yourself.

In such cases - you can also drop the $URL_Display parameter and add the list URL manually, adding "?ID={@ID}" yourself.

Please let me know if there are any more questions, here or by mail: shai at kwizcom.com

Anonymous said...

Awesome! Thank you so much! I have been struggling with this all day.

Anonymous said...

Hi Shai,

I have created a Data View WebPart using SharePoint designer. I have added filter on DVWP & also have selected the option of 'enable sorting and filtering on column header'. Now when I pass “Select * from tablename” sql query, then ‘clear this filter ‘with drop down menu on column header works fine but when I add the filter with “Where” clause then it doesn’t work & clicking on ‘Ascending/Descending’ gives error.

AshishChotalia said...

Hello Sai,

Is there any way through which to convert DVWP with out using sharepoing designer.

I am going to creat webpart from abother one and want to provide built in functionality of exporting it.

Plz provide some help.

Thanks,
Ashish

Shai Petel said...

Hi Ashis,

I do not know a way of creating data view without SPD.

Technically - it is possible, since the DVWP is installed with WSS, but you will not have a designer for it.

You can however, build your own designer and create a DVWP webpart by code, You will just have to code a lot of XML in order to achieve it.

(or maybe a new site actions menu? "convert list view to DVWP" that will automate that part)

AshishChotalia said...

Thnaks for the reply,


I think u didn't get my question.

My Question is I am having configuration webpart, through which I want to create template/Webpart and want to export it to webpart gallery.Meanwhile i want to save it to XSLT file manually.(Right now if we are going to have export functionality for webpart than we need to go to Sharepoint designer and convert it to XSLT format).
Same portion i just want to save programatically.