This is a migrated thread and some comments may be shown as answers.

GridView Grouping and Paging Collapsed Groups by Default

1 Answer 1037 Views
Grid
This is a migrated thread and some comments may be shown as answers.
erwin
Top achievements
Rank 1
Veteran
Iron
erwin asked on 24 Aug 2018, 10:10 AM

Hi,
My grid uses Ajax to load its entire content at initial load.Paging/Filtering/Sorting all done locally afterwards. I would like to enable interactive Grouping that mimics as closely as possible the Telerik Windows Forms Grid.

When the user groups on a column, the grid should display initially collapsed groups with as many group headers as fit into the given page size. Ideally, The group headers should also indicate the number of child rows in the group. In addition I should be able to sort the group headers according to the count of members (largest group first).
I had a look at documentation but most samples seem to use the databind event which is as far as I know not fired when the user selects grouping after data load.
I'm a beginner with ASP.NET MVC so I might have missed the obvious.

Thanks and kind regards
Erwin

1 Answer, 1 is accepted

Sort by
0
Preslav
Telerik team
answered on 28 Aug 2018, 11:12 AM
Hi Erwin,

When the Grid is grouped, a grouping logic runs in the dataSource. After that, the Grid rebinds, and the dataBound event is fired again. Thus, feel free to add the desired logic in the dataBound event handler. Also, you could take advantage of the group event handler.
Further, about the other requirements, showing the groups as collapsed by default is not possible out of the box. This could be achieved by adding additional logic, for example, check the JavaScript from this KB article:
About the group headers based on the page size, for the time being, this functionality is not possible due to the current implementation of the dataSource groups. The only possible workaround is to change the pageSize on the fly.
About the number of child rows, to achieve this, use the Count aggregate of the dataSource. For example, check this demo:
Finally, I am sorry to say that sorting groups based on the count is not achievable, for now. It would be doable after the following enhancement is implemented.
I hope the above is useful.


Regards,
Preslav
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
erwin
Top achievements
Rank 1
Veteran
Iron
Answers by
Preslav
Telerik team
Share this question
or