Monday 3 February 2014

XSLT Conditional formatting for sharepoint 2013


<Xsl>
<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal" xmlns:o="urn:schemas-microsoft-com:office:office">
  <xsl:include href="/_layouts/xsl/main.xsl"/>
  <xsl:include href="/_layouts/xsl/internal.xsl"/>
  <xsl:param name="AllRows" select="/dsQueryResponse/Rows/Row[$EntityName = '' or (position() &gt;= $FirstRow and position() &lt;= $LastRow)]"/>
  <xsl:param name="dvt_apos">&apos;</xsl:param>
<xsl:template name="FieldRef_Hyperlink_URL_body.Details" ddwrt:dvt_mode="body" match="FieldRef[(@Format='Hyperlink') and @Name='Details']" mode="URL_body" ddwrt:ghost="">
    <xsl:param name="thisNode" select="."/>
    <xsl:variable name="url" select="$thisNode/@*[name()=current()/@Name]" />
    <xsl:variable name="desc" select="$thisNode/@*[name()=concat(current()/@Name, '.desc')]" />
    <xsl:choose>
      <xsl:when test="$url=''">
        <xsl:if test="$desc=''">
          <xsl:value-of select="$desc"/>
        </xsl:if>
      </xsl:when>
      <xsl:otherwise>
        <xsl:choose>
<xsl:when test="$desc=''">
              <xsl:value-of select="$url" /></xsl:when>
<xsl:otherwise>
<a href="{$url}"><img alt="Status" src="../../../Style Library/Images/img-icon-discuss.png" border="0" /></a>
</xsl:otherwise>
</xsl:choose>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

<xsl:template name="FieldRef_header.Approvers" ddwrt:dvt_mode="header" match="FieldRef[@Name='Approvers']" mode="header" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">
    <th nowrap="nowrap" scope="col" onmouseover="OnChildColumn(this)" style="width: 81px">
      <xsl:attribute name="class">
        <xsl:choose>
          <xsl:when test="(@Type='User' or @Type='UserMulti') and ($PresenceEnabled='1')">ms-vh</xsl:when>
          <xsl:otherwise>ms-vh2</xsl:otherwise>
         </xsl:choose>
      </xsl:attribute>
      <xsl:call-template name="dvt_headerfield">
        <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>
  </xsl:template>
<xsl:template name="FieldRef_header.Document_x0020_Status" ddwrt:dvt_mode="header" match="FieldRef[@Name='Document_x0020_Status']" mode="header" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">
    <th nowrap="nowrap" scope="col" onmouseover="OnChildColumn(this)" style="width: 191px">
      <xsl:attribute name="class">
        <xsl:choose>
          <xsl:when test="(@Type='User' or @Type='UserMulti') and ($PresenceEnabled='1')">ms-vh</xsl:when>
          <xsl:otherwise>ms-vh2</xsl:otherwise>
         </xsl:choose>
      </xsl:attribute>
      <xsl:call-template name="dvt_headerfield">
        <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>
  </xsl:template>
<xsl:template name="FieldRef_printTableCell_EcbAllowed.Approvers" match="FieldRef[@Name='Approvers']" mode="printTableCellEcbAllowed" ddwrt:dvt_mode="body" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">
    <xsl:param name="thisNode" select="."/>
    <xsl:param name="class" />
    <td style="width: 81px">
      <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:apply-templates select="." mode="PrintFieldWithECB">
        <xsl:with-param name="thisNode" select="$thisNode"/>
      </xsl:apply-templates>
    </td>
  </xsl:template>
<xsl:template name="FieldRef_printTableCell_EcbAllowed.Document_x0020_Status" match="FieldRef[@Name='Document_x0020_Status']" mode="printTableCellEcbAllowed" ddwrt:dvt_mode="body" ddwrt:ghost="">
    <xsl:param name="thisNode" select="."/>
    <xsl:param name="class" />
    <td>
<xsl:attribute name="style">
<xsl:if test="normalize-space($thisNode/@Document_x0020_Status) = 'Draft in Progress'" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:cf_explicit="1">color: #FAAC32; font-weight: bold; background-image: url(&apos;../../../Style Library/Images/img-icon-inprogress.png&apos;); background-repeat: no-repeat; background-position: right center;</xsl:if>
<xsl:if test="normalize-space($thisNode/@Document_x0020_Status) = 'Assigned to 3rd party Lawyer'" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:cf_explicit="1">color: #FAAC32; font-weight: bold; background-image: url(&apos;../../../Style Library/Images/img-icon-inprogress.png&apos;); background-repeat: no-repeat; background-position: right center;</xsl:if>
<xsl:if test="normalize-space($thisNode/@Document_x0020_Status) = 'Assigned to 3rd Party Lawyer'" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:cf_explicit="1">color: #FAAC32; font-weight: bold; background-image: url(&apos;../../../Style Library/Images/img-icon-inprogress.png&apos;); background-repeat: no-repeat; background-position: right center;</xsl:if>
<xsl:if test="normalize-space($thisNode/@Document_x0020_Status) = 'Approval in Progress'" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:cf_explicit="1">color: #FAAC32; font-weight: bold; background-image: url(&apos;../../../Style Library/Images/img-icon-inprogress.png&apos;); background-repeat: no-repeat; background-position: right center;</xsl:if>
<xsl:if test="normalize-space($thisNode/@Details) = 'Review in progress'" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:cf_explicit="1">color: #FAAC32; font-weight: bold; background-image: url(&apos;../../../Style Library/Images/img-icon-inprogress.png&apos;); background-repeat: no-repeat; background-position: right center;</xsl:if>
<xsl:if test="normalize-space($thisNode/@Document_x0020_Status) = 'Review in progress'" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:cf_explicit="1">color: #FAAC32; font-weight: bold; background-image: url(&apos;../../../Style Library/Images/img-icon-inprogress.png&apos;); background-repeat: no-repeat; background-position: right center;</xsl:if>
<xsl:if test="normalize-space($thisNode/@Document_x0020_Status) = 'Approver Rejected'" ddwrt:cf_explicit="1" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">color: #FF0000; font-weight: bold; background-image: url(&apos;../../../Style Library/Images/img-icon-rejected.png&apos;); background-repeat: no-repeat; background-position: right center;</xsl:if>

<xsl:if test="normalize-space($thisNode/@Document_x0020_Status) = 'Reviewer Rejected'" ddwrt:cf_explicit="1" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">color: #FF0000; font-weight: bold; background-image: url(&apos;../../../Style Library/Images/img-icon-rejected.png&apos;); background-repeat: no-repeat; background-position: right center;</xsl:if>
<xsl:if test="normalize-space($thisNode/@Document_x0020_Status) = 'Pending Signature'" ddwrt:cf_explicit="1" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">color: #FAAC32; font-weight: bold; background-image: url(&apos;../../../Style Library/Images/img-icon-inprogress.png&apos;); background-repeat: no-repeat; background-position: left center;</xsl:if>

<xsl:if test="normalize-space($thisNode/@Document_x0020_Status) = 'Pending Signature'" ddwrt:cf_explicit="1" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">color: #FAAC32; font-weight: bold; background-image: url(&apos;../../../Style Library/Images/img-icon-inprogress.png&apos;); background-repeat: no-repeat; background-position: right center;</xsl:if>

<xsl:if test="normalize-space($thisNode/@Document_x0020_Status) = 'Not Started'" ddwrt:cf_explicit="1" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">color: #FAAC32; font-weight: bold; background-image: url(&apos;../../../Style Library/Images/img-icon-inprogress.png&apos;); background-repeat: no-repeat; background-position: right center;</xsl:if>
<xsl:if test="normalize-space($thisNode/@Document_x0020_Status) = 'Active'" ddwrt:cf_explicit="1" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">background-image: url(&apos;../../../Style Library/Images/img-icon-approved.png&apos;); background-repeat: no-repeat; background-position: right center; font-weight: bold; color: #56C553;</xsl:if>
<xsl:if test="normalize-space($thisNode/@Document_x0020_Status) = 'Over Due'" ddwrt:cf_explicit="1" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">color: #FF0000; font-weight: bold; background-image: url(&apos;../../../Style Library/Images/Overdue(2).png&apos;); background-repeat: no-repeat; background-position: right center;</xsl:if>

</xsl:attribute>

      <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:apply-templates select="." mode="PrintFieldWithECB">
        <xsl:with-param name="thisNode" select="$thisNode"/>
      </xsl:apply-templates>
    </td>
  </xsl:template>
<xsl:template name="FieldRef_header.Details" ddwrt:dvt_mode="header" match="FieldRef[@Name='Details']" mode="header" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">
    <th nowrap="nowrap" scope="col" onmouseover="OnChildColumn(this)" style="width: 69px">
      <xsl:attribute name="class">
        <xsl:choose>
          <xsl:when test="(@Type='User' or @Type='UserMulti') and ($PresenceEnabled='1')">ms-vh</xsl:when>
          <xsl:otherwise>ms-vh2</xsl:otherwise>
         </xsl:choose>
      </xsl:attribute>
      <xsl:call-template name="dvt_headerfield">
        <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>
  </xsl:template>
<xsl:template name="FieldRef_printTableCell_EcbAllowed.Details" match="FieldRef[@Name='Details']" mode="printTableCellEcbAllowed" ddwrt:dvt_mode="body" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">
    <xsl:param name="thisNode" select="."/>
    <xsl:param name="class" />
    <td style="width: 69px">
      <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:apply-templates select="." mode="PrintFieldWithECB">
        <xsl:with-param name="thisNode" select="$thisNode"/>
      </xsl:apply-templates>
    </td>
  </xsl:template>
</xsl:stylesheet></Xsl>

No comments:

Post a Comment