2

Say I want to grab a choice field via xsl. What is the right binding for mode? I can't find this information anywhere, and I've tried everything in its place!

  • Text_body ?
  • Choice_body ?
  • MultiChoice_body ?

    <xsl:template match="FieldRef[@Name='myChoice']" mode="Choice_body">
        <xsl:param name="thisNode" select="."/>
        <td class="someclass">{$thisNode/@myChoice}</td>
    </xsl:template>
    

Does anyone have a clue?

[Later...] It's been awhile now, I guess this is a hard question.

bgmCoder
  • 3,581
  • 16
  • 61
  • 102

1 Answers1

5

In order to define Custom Rendering for a SPFieldChoice in template for mode attribute should be used value body

For example, if we apply for Tasks list that contains Status field (SPFieldChoice) the following XSLT style sheet

<xsl:template match ="FieldRef[@Name='Status']" mode="body">
    <xsl:param name="thisNode" select="."/>
    <xsl:choose>
            <xsl:when test="$thisNode/@Status='Not Started'">
                <img src="/_layouts/images/tasknotdone.gif"/>
            </xsl:when>
            <xsl:when test="$thisNode/@Status='In Progress'">
                <img src="/_layouts/images/taskpane.gif"/>
            </xsl:when>
            <xsl:when test="$thisNode/@Status='Completed'">
                <img src="/_layouts/images/taskdone.gif"/>
            </xsl:when> 
            <xsl:otherwise>
                <xsl:value-of select="$thisNode/@Status" />
            </xsl:otherwise>                
        </xsl:choose>
  </xsl:template>

the List View will be rendered as shown below

enter image description here

Hope this helps,

Vadim

Vadim Gremyachev
  • 42,498
  • 3
  • 86
  • 167