locked
Trim the lenght of comments in a view RRS feed

  • Question

  • Hi 

    We have comments column in a document library view and the users use almost the 255 character limit for the comments for each documents.So this reduces the view of users  to see more docs at once/ at a glance.

    So, We are looking for a solution to trim the text in the view and add a tool tip for the comments.

    Any suggestions??

     

    Thank you

    Eswar


    EK
    Thursday, July 28, 2011 6:01 PM

Answers

  • 1. Open the site in SharePoint designer , navigate to the list default view page.(Assuming AllItems.aspx page)
    .
    2. 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.
    3. 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" />
    </div></TD>
    
    .
    We need to change the above line of code as below
    .
    <TD Class="{$IDAXNQ1G}">
    <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:when>
    <xsl:otherwise> 
          <xsl:value-of disable-output-escaping="yes" select="@remarks" />
    </xsl:otherwise>
    </xsl:choose>
    </div></TD>
    
    .
    4. Save the file. Now you will see the trimmed text in the default view page
     

    --Cheers


    • Marked as answer by Emir Liu Friday, August 5, 2011 6:29 AM
    Saturday, July 30, 2011 10:48 AM
    • Marked as answer by Emir Liu Friday, August 5, 2011 6:29 AM
    Tuesday, August 2, 2011 5:47 AM

All replies

  • Hi,

    This can be carried out in a number of ways.

    However I would suggest this:

    1. Change the comment column type as single line of text.

    2. Edit the view and place it at last in the view.

    Thanks,

    Rahul Rashu

    Thursday, July 28, 2011 8:09 PM
  •  

    Thanks for your suggestions rashu.

    1. I am aware of the single line of text but our users request for multiline.

    2. Though it is moved to the last place. We cannot view more docs at once or at a glance.


    EK
    Thursday, July 28, 2011 11:30 PM
  • 1. Open the site in SharePoint designer , navigate to the list default view page.(Assuming AllItems.aspx page)
    .
    2. 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.
    3. 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" />
    </div></TD>
    
    .
    We need to change the above line of code as below
    .
    <TD Class="{$IDAXNQ1G}">
    <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:when>
    <xsl:otherwise> 
          <xsl:value-of disable-output-escaping="yes" select="@remarks" />
    </xsl:otherwise>
    </xsl:choose>
    </div></TD>
    
    .
    4. Save the file. Now you will see the trimmed text in the default view page
     

    --Cheers


    • Marked as answer by Emir Liu Friday, August 5, 2011 6:29 AM
    Saturday, July 30, 2011 10:48 AM
  • Create a dataview web part on a separate page and direct your users to see that dataview instead of the default "AllItems" view. In your dataview, use Text/String functions to show certain number of characters from the comment column (i.e. substring).

    Pretty much same idea as what Prasath suggested above, but I personally like to create separate dataview instead of modifying the views that come out of the box, which you can modify in browser as you need.

     


    Pman
    http://www.pmansLab.com/
    Saturday, July 30, 2011 3:57 PM
    • Marked as answer by Emir Liu Friday, August 5, 2011 6:29 AM
    Tuesday, August 2, 2011 5:47 AM