Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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

share|improve this answer
    
Hey! That did it! +1 solved! However, I like to use css, so instead of img tags, I inserted: <span class="statusRating3"></span> and then used my css to insert the icons as background images. –  BGM Dec 25 '12 at 18:35
    
Glad it helped:) –  Vadim Gremyachev Dec 25 '12 at 18:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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