Saturday, July 30, 2011

Trim the text in the multiple line of text field in a list and add a tool tip using SharePoint Designer 2007

1. This is the sample list which is currently displaying full text from multiple line of text field “Remarks"
Multiline of text

2. Open the site in SharePoint designer , navigate to the list default view page.(In this example we are using AllItems.aspx page)

3. Right click on the List View Web Part and select “Convert to XSL T Data View”. This will automatically convert settings for the current view into data view parameters.
Convert to XSLT DataView

4. After converting to XSLT, select the remarks field and switch to code view, you will see the code to display the remarks field as below

<TD Class="{$IDAWNV5H}"><div dir="{ddwrt:GetVar('Direction')}">
<xsl:value-of disable-output-escaping="yes" select="@remarks" />

 We need to change the above line of code as below

<TD Class="{$IDAXNQ1G}" style="height: 22px">
<div dir="{ddwrt:GetVar('Direction')}" title="{@remarks}">
<xsl:choose >
<xsl:when test="@remarks != ''" >
<xsl:value-of disable-output-escaping="yes" select='concat((substring(@remarks,1,20)),"...")' />
<xsl:value-of disable-output-escaping="yes" select="@remarks" />

 5. Save the file. Now you will see the trimmed text in the default view page

Trim multi-line of text column

No comments:

Post a Comment