Sunday, 13 November 2011

Truncate description field in a ListviewWebpart - SharePoint 2010


In SharePoint 2010 if you add a ListviewWebPart on the Page, you would not get its xslt in UI to modify. So how do you truncate the text for any field?

Well Designer is here to rescue. Follow the steps -

1. Edit the Page in designer.
2. Select the ListviewWebPart and in the Ribbon click on Design tab.
3. Click on Customize XSLT -> Customize Entire View.
4. Next in your UI of the Page click on the description field or whatever field you need to truncate. For example, mine was the description field and replace it.

Field -
<xsl:value-of select="$thisNode/@*[name()=current()/@Name],0,250" disable-output-escaping="yes"/>

Replace With - <xsl:value-of select="substring($thisNode/@*[name()=current()/@Name],0,250)" disable-output-escaping="yes"/>...

the above will truncate the description field to 250 characters.
5. Save the Page and Exit.

Ads by Google

No comments:

Post a Comment