0

Hi I've been working on my csom application and needed a way to group list items via an attribute. This also needed to be paginated as well.

Initially I just went for groupBy, seemed to be what I needed to get the unique attributes and then I would get the counts and go from there.

As we all know now though groupBy doesn't do this. So I looked harder and it does have this collapse and GroupLimit. I thought that would be good as it would limit the numbers in each group. Again no. No matter what I put as the collapse (true or false)

The rowLimit for the whole query is respected but is used for each row returned.

So that me to looking at my query with an orderBy and groupBy and it seemed I was doing the counts for each group. It didn't do the GroupLimit (which would have been nice). So I dropped it and what happened to my results - nothing - same as before!

So I ask what is the point of GroupBy? - what is it meant to do?!

1

The <GroupBy> element is used by SharePoint's built in "list view" web part(s) and has been since SharePoint 2007.

From the official documentation:

Contains a Group By section for grouping the data returned through a query in a list view.

(emphasis mine)

Since it's primarily (only?) used by the built-in list view UI for displaying results, it does not serve a purpose when you are composing your own queries and displaying the results through another mechanism.

See also the answer to this question.

  • Yeah, it seems to be only something within SharePoint. Just seems that it could be more, I guess that's sharepoint 2010 for you. – Richard Housham Mar 31 '17 at 9:20
  • 1
    I would add that with SharePoint 2013 and SPList.RenderListData method, the GroupBy element can now be used when retrieving data with custom code, even though its primary purpose is to support client-side rendering. – Reego Apr 25 '17 at 14:37

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.