简体   繁体   中英

Compute columns in SharePoint Designer 2010 AllItems.aspx xslt view

Could you please help me to implement following:

I have custom list with 3 columns (LinkTitle, Location, Location2). If column Location2 is empty, it should take values from Location column

I've made following, doesn't work:

<xsl:template name="FieldRef_header.Location2" ddwrt:dvt_mode="header" match="FieldRef[@Name='Location2']" mode="header" ddwrt:ghost="hide">
<th nowrap="nowrap" scope="col" onmouseover="OnChildColumn(this)">
  <xsl:attribute name="class">
    <xsl:choose>
        <xsl:when test="@Location2 != ''">
            <xsl:value-of select="@Location2" />
        </xsl:when>
        <xsl:otherwise>
            <xsl:value-of select="@Location" />
        </xsl:otherwise>
    </xsl:choose>
  </xsl:attribute>
  <xsl:call-template name="dvt_headerfield.Location2">
    <xsl:with-param name="fieldname">
      <xsl:value-of select="@Name"/>
    </xsl:with-param>
    <xsl:with-param name="fieldtitle">
      <xsl:value-of select="@DisplayName"/>
    </xsl:with-param>
    <xsl:with-param name="displayname">
      <xsl:value-of select="@DisplayName"/>
    </xsl:with-param>
    <xsl:with-param name="fieldtype">
        <xsl:choose>
            <xsl:when test="@Type='Number' or @Type='Currency'">number</xsl:when>
            <xsl:otherwise>x:string</xsl:otherwise>
        </xsl:choose>
    </xsl:with-param>
  </xsl:call-template>
</th>

Can't you do it with an additional Current Location Column of Calculated type, and Formula:

=IF( ISBLANK(Location2) , Location , Location2 )

That's the SharePoint Way

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM