1

I have a list with two lookup columns. Each allow multiple selections. I will say right of the bat that I am limited by admins to only using the XSLT List View web part. The DataView Web part not available on the site.

The lookup column displays results as "one;two;three..." All on one line and without a space after the semi-colon. I found a solution online using the DataView web part but I cannot get it to work on the XSLT List View web part. https://deannaschneider.wordpress.com/2012/07/09/displaying-multiple-select-fields-one-per-row-in-a-dataview-web-part/

Anyone know who to get this working on the XSLT List View web part?

  • This is for SP2010? At what point are you experiencing problems? – Jan Jouke Tjalsma Mar 31 '15 at 22:04
1

I had exactly the same problem and I solved it.

I hava a multi value Lookup Field named "g_x00fc_ltig_x0020_in_x0020__x0028_lang", where I want to display each selection in a new line instead of the default ";" separators.

You must substitute my field name by your field name.

I went into SharePoint Designer 2010 and opened my .aspx view. In the code I searched for the "xsl:template" tag (last line in my code snippet) and copied the following code just in front of the searched tag:

<xsl:template name="string-replace-all">
<xsl:param name="text" />
<xsl:param name="replace" />
<xsl:param name="by" />
<xsl:choose>
    <xsl:when test="contains($text, $replace)">
        <xsl:value-of select="substring-before($text,$replace)" />
        <xsl:value-of select="$by" />
        <xsl:call-template name="string-replace-all">
        <xsl:with-param name="text" select="substring-after($text,$replace)" />
        <xsl:with-param name="replace" select="$replace" />
        <xsl:with-param name="by" select="$by" />
        </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
        <xsl:value-of select="$text" />
    </xsl:otherwise>
</xsl:choose>

<xsl:template name="FieldRef_printTableCell_EcbAllowed.g_x00fc_ltig_x0020_in_x0020__x0028_lang_x0029_" match="FieldRef[@Name='g_x00fc_ltig_x0020_in_x0020__x0028_lang_x0029_']" mode="printTableCellEcbAllowed" ddwrt:dvt_mode="body" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">
    <xsl:param name="thisNode" select="."/>
    <xsl:param name="class" />
<td>
    <xsl:if test="@ClassInfo='Menu' or @ListItemMenu='TRUE'">
        <xsl:attribute name="height">100%</xsl:attribute>
        <xsl:attribute name="onmouseover">OnChildItem(this)</xsl:attribute>
  </xsl:if>
    <xsl:attribute name="class">
        <xsl:call-template name="getTDClassValue">
            <xsl:with-param name="class" select="$class" />
            <xsl:with-param name="Type" select="@Type"/>
            <xsl:with-param name="ClassInfo" select="@ClassInfo"/>
        </xsl:call-template>
  </xsl:attribute>


    <xsl:variable name="thisRow">
        <xsl:call-template name="string-replace-all">
        <xsl:with-param name="text" select="$thisNode/@*[name()=current()/@Name]"/>
        <xsl:with-param name="replace" select="';'" />
        <xsl:with-param name="by" select="'&lt;br /&gt;'" />
        </xsl:call-template>
    </xsl:variable>
    <xsl:value-of select="$thisRow" disable-output-escaping="yes"/>
</td>
</xsl:template>

The first template in the code is the given string-replace function from your reference.

The second template I have generated by formatting my column with a background color in SharePoint Designer and removed the "style" and "color" from the tag and additinally some other not needed code lines.

I added the code between and including the lines containing "thisRow".

Save it, and voila – it works.

Kind regards Ernst

  • I was missing the '&lt; and &gt;' around the br. Was using different coding to replace the < and >. Thanks! – Martin May 13 '15 at 18:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.