How to collapse group by column name?

Hello,

I have two grouping columns. I want to collapse second group column on first load. How can it be done.


Regards,

Krailit


1 Reply 1 reply marked as answer

JC Joseph Christ Nithin Issack Syncfusion Team April 29, 2022 01:22 PM UTC

Hi Krailit,


  Greetings from Syncfusion support.


  Based on your query, you want to collapse only the second grouped column in your grid. This can be achieved by using the `grid.groupModule.expandCollapseRows` method in the dataBound event of the EJ2 Grid.


Please refer the below code example.


 

dataBound() {

    if (this.initial) {

      this.initial = false;

      var groupedRecords = this.grid

        .getContentTable()

        .querySelectorAll('.e-recordplusexpand');

      groupedRecords.forEach((itemindex=> {

        if (item.getAttribute('ej-mappingname') === 'Country') {

          this.grid.groupModule.expandCollapseRows(item);

        }

      });

    }

  }

 


Sample: https://stackblitz.com/edit/angular-9e6tzs?file=app.component.ts


Please get back to us for further details.


Regards,

Joseph I.


Marked as answer
Loader.
Up arrow icon