Custom xsl rendering for lookup field in list view RRS feed

  • Question

  • I'm trying to change rendering of a list column on list view page in SharePoint Server 2010.

    After a few tutorials and some hair pulling I managed to create an xslt for a calculated and currency field that changes the way fields render. From my fldtypes_XXXXXX.xsl):

    <xsl:template match ="FieldRef[@Name='MarkCalc']" mode="Text_body">
     <xsl:param name="thisNode" select="."/>
     <xsl:value-of select="$thisNode/@*[name()=current()/@Name]" disable-output-escaping ="yes"/>
    <xsl:template match="FieldRef[@Name='CurrencyTest']" mode="Number_body">
     <xsl:param name="thisNode" select="."/>
     <b><xsl:value-of disable-output-escaping="yes" select="$thisNode/@*[name()=current()/@Name]" /></b>

    Then I tried to do the same for a lookup field, but it just won't work. This is my last attempt (I copied it from SharePoint designer, I have already tried it without "Encoded" part). What am I missing?

    <xsl:template match="FieldRef[(@Encoded) and @Name='Lookup1']" mode="Lookup_body">
     <xsl:param name="thisNode" select="."/>
     <b><xsl:value-of select="$thisNode/@*[name()=current()/@Name]" disable-output-escaping="yes" /></b>

    Monday, May 31, 2010 8:57 AM

All replies

  • While you're showing what you did, what is it that you're trying to achieve?
    w: | t: @waldekm | c: | c:
    Monday, May 31, 2010 8:52 PM
  • Hi Waldek,

    The idea is to create a custom field type that inherits from lookup and custom render it for list view and display, new and edit form.

    I've already done display, new and edit part, but got to a screeching halt on list view rendering.

    The xsl I've posted is from my test project to confirm that my custom fldtypes_*.xsl is loading correctly, which it is since the custom rendering for currency and calculated field is indeed working.

    Yesterday, I've tried to edit SharePoint's /layouts/xsl/fldtypes.xsl directly and changed  lookup template, to confirm I'm overriding correct one (again, I am). And finally, I've put my template directly after the one I'm overriding, and it worked. Here is the part of SharePoint's fldtypes.xsl that I've changed:

     <!-- SharePoint default template -->
     <xsl:template match="FieldRef[@Encoded]" ddwrt:dvt_mode="body" mode="Lookup_body">
      <xsl:param name="thisNode" select="."/>
      <xsl:value-of select="$thisNode/@*[name()=current()/@Name]" disable-output-escaping="yes" />
     <!-- Custom template -->
     <xsl:template match="FieldRef[(@Encoded) and @Name='Lookup1']" ddwrt:dvt_mode="body" mode="Lookup_body">
      <xsl:param name="thisNode" select="."/>
       <xsl:value-of select="$thisNode/@*[name()=current()/@Name]" disable-output-escaping="yes" />

    This last action worked and my lookup with name 'Lookup1' is displaying in bold. Of course this cannot be the solution since I don't want to change core SharePoint file in the process.

    Tuesday, June 1, 2010 9:08 AM
  • Hi vrivrox,

    I have the same problem.

    I follow the guide

    and create a text field.

    Everything works ok except the xsl file.

    In the guide , the background-color is lightgreen  but it is so light and I set the color to red, but it doesn't work at all

    any idea?



    Sunday, June 13, 2010 7:45 AM
  • Kevin,

    Could you provide more detail about why you say "it doesn't work at all"?  Do you mean the background color is light green if you set background-color to "lightgreen" but the background color is not red if you se background-color to "red"?


    Tuesday, July 13, 2010 12:18 AM
  • add priority property value works for me.

    <xsl:template match="FieldRef[(@Encoded) and @Name='Lookup1']" priority="1" mode="Lookup_body"><xsl:template match="FieldRef[(@Encoded) and @Name='Lookup1']" priority="1" mode="Lookup_body">

    Tuesday, July 16, 2019 8:08 AM