Collapse all grid rows

2 Answers 4234 Views
General Discussions
desi
Top achievements
Rank 1
desi asked on 25 Oct 2018, 03:30 AM

Is it possible to collapse all rows or expend only one row at a time?

 

I've already tried this

https://www.telerik.com/kendo-angular-ui/components/grid/api/GridComponent/#toc-expandrow

 

 

Thank you in advance

2 Answers, 1 is accepted

Sort by
0
Dimiter Topalov
Telerik team
answered on 25 Oct 2018, 01:50 PM
Hello Desi,

Using the Grid expandRow() and collapseRow() methods is indeed the built-in approach for expanding/collapsing a master Grid row programmatically.

To expand or collapse all master Grid rows you can call the respective method for each Grid row in a loop, passing all row indexes consecutively.

Expanding/collapsing one row at a time is the default behavior when using the UI +/- icons and you can do this by programmatically too by calling expandRow() or collapseRow() passing the respective row index.

Here is an example demonstrating both expanding and collapsing all master Grid rows:

https://stackblitz.com/edit/angular-k7mqnd-zn8epb?file=app/app.component.ts

On a side note, if the scenario involves a groupable Grid (as opposed to a master-detail one), and the question is about expanding and collapsing Grid groups, the respective methods are collapseGroup() and expandGroup().

I hope this helps, but if I am missing something, please describe the scenario, the described functionality, and how is differing from the observed one in further details, so I can try providing a solution that is best suitable to the specific use case. Thank you in advance.

Regards,
Dimiter Topalov
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.
AGISDev
Top achievements
Rank 1
commented on 24 Apr 2019, 05:33 PM

In my case, I'm using Virtual Scrolling and want to collapse group headers.  Collapsing only occurs up to the pageSize value (80).  Is it possible to collapse/expand all groups in the gird? 
0
Svet
Telerik team
answered on 26 Apr 2019, 05:35 AM
Hi,

When using virtual scrolling, the Grid renders just a number of rows equal to the pageSize. This is done for optimization purposes. This is why, we are able to collapse only the group headers of the data items that are currently loaded by the Grid.

What could be done is to collapse the loaded group headers on each (pageChange) event or pre-load the whole data initially, which will allow to collapse all groups at once. However, both approaches would impose drawbacks related to performance. Unfortunately, there does not seem to be another way of achieving the desired behavior in a Grid with virtual scrolling.

Regards,
Svetlin
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
General Discussions
Asked by
desi
Top achievements
Rank 1
Answers by
Dimiter Topalov
Telerik team
Svet
Telerik team
Share this question
or