3

When I enable grouping in the CQWP I can sort in either ascending or descending order based on the values in the field by which I'm grouping. How do I customize that sort order?

For instance, let's say I have a field "PersonType" which has three values: "Players", "Coaches", and "Officials". If I group by field "PersonType" my groups will either be "Coaches", "Officials", and "Players", if I sort ascending, or "Players", "Officials", "Coaches" if I sort descending. How do I customize that sort order?

3

You can use the XSLT <xsl:sort> element to customize your sort order.

https://sites.google.com/site/icsharepoint2010/xslt/sorting-in-xslt

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  version="1.0">
  <xsl:output method="text"/>

  <xsl:template match="employees">
    <xsl:apply-templates>
      <xsl:sort select="salary"/>
    </xsl:apply-templates>
  </xsl:template>

  <xsl:template match="employee">
    Last:      <xsl:apply-templates select="last"/>
    First:     <xsl:apply-templates select="first"/>
    Salary:    <xsl:apply-templates select="salary"/>
    Hire Date: <xsl:apply-templates select="@hireDate"/>
    <xsl:text>
  </xsl:text>

  </xsl:template>
</xsl:stylesheet>

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.