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

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?

share|improve this question

1 Answer 1

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>
share|improve this answer
    
Would that be something I add to ItemStyles.xsl? –  Chloraphil Nov 6 '13 at 14:06
    
Yes. Your ItemStyle.xsl and ContentQueryMain.xsl handle the rendering of the data fetched by the CQWP. See here for more details. msdn.microsoft.com/en-us/library/bb447557(v=office.12).ASPX –  Vardhaman Deshpande Nov 6 '13 at 14:08

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.