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

collapse Group Error

1 Answer 155 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
bhavin
Top achievements
Rank 1
bhavin asked on 10 Oct 2018, 01:37 PM

By Default I want my grid to be collapsed I tried

 

  @ViewChild('grid') public grid;
public () {

    this.gridView1.data.forEach((gr, idx) => this.grid.collapseGroup(idx.toString()));
  }

 

and calling this method on button click however it is not working and throwing an error data undefined when I did define data and kept it public. 

If you have a example that would be great

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimiter Topalov
Telerik team
answered on 11 Oct 2018, 01:41 PM
Hello Bhavin,

The attempted approach seems correct - just make sure that "this.gridView1.data" is actually an array of arrays (the data structure the grouped Grid expects). Here is a runnable example demonstrating this approach:

https://stackblitz.com/edit/angular-a6dnrt?file=app/app.component.ts // automatically on AfterViewInit

https://stackblitz.com/edit/angular-a6dnrt-m1hw5h?file=app/app.component.ts // upon clicking a button

A possible reason for the described error would be an attempt to collapse the Grid groups while the data is not grouped and is a regular array (as opposed to an object of type GridDataResult that has "data" property - an array, and a total property - the total number of items for paging purposes).

I hope this helps.

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.
Tags
General Discussions
Asked by
bhavin
Top achievements
Rank 1
Answers by
Dimiter Topalov
Telerik team
Share this question
or