3

I have content query webpart that queries data from a custom list and I am using a custom xsl style to display the items everything works fine. The issue that I have is I have a column called Category which I use to group by the results of the query , I am trying to make that column clickable e.g if I have categories A, B , C , D if users click on A the link should take them to all the items under that category. Please assist

2

Let you have below information:

<Person>
    <Student>
        <Info Country="England" Name="Rich" Age="20" Class="C" />
    </Student>
    <Student>
        <Info Country="Canada" Name="Richard" Age="20" Class="B" />
    </Student>
    <Student>
        <Info Country="England" Name="Sam" Age="21" Class="A" />
    </Student>
    <Student>
       <Info Country="Australia" Name="David" Age="22" Class="D" />
    </Student>
    <Student>
        <Info Country="Australia" Name="Andy" Age="24" Class="A" />
    </Student>
</Person>

Here, if you want to group by country, then you can start with below code snippet:

<xsl:template match="Person">
  <xsl:for-each-group select="Student/Info" group-by="@Country">
    <country name="{current-grouping-key()}">

    </country>
  </xsl:for-each-group>
</xsl:template>

Now if you want to further group the Info elements by each country group so you can group by using class

<xsl:template match="Person">
  <xsl:for-each-group select="Student/Info" group-by="@Country">
    <country name="{current-grouping-key()}">
      <xsl:for-each-group select="current-group()" group-by="@Class">
        <student name="{current-grouping-key()}">
          <classes>
            <xsl:for-each select="current-group()">
              <name><xsl:value-of select="@Name"/></name>
            </xsl:for-each>
          </classes>
        </student>
      </xsl:for-each-group>
    </country>
  </xsl:for-each-group>
</xsl:template>
| improve this answer | |

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.