Vlad Danila
Vlad Danila

Reputation: 1382

Access group row ag-grid

When using the row grouping feature provided by the ag-Grid, there is inserted a new 'row' as the header of the group, the click expand / collapse area which identifies that group.

Is there any way to access this row?

It is not present in row data which populates the grid.

 this.autoGroupColumnDef = { 
      field: "column",
      headerName: " Column containing the expand / collapse rows ",
      valueGetter:  function nameGetter(params) {
       console.log("All rows: ", params.data); // group rows not present here
       return params.data.nameToDisplay;
      }
    }

Upvotes: 1

Views: 1142

Answers (1)

Arcot Deepika
Arcot Deepika

Reputation: 449

Since there is no clarity with the above code, I can just suggest you to identify which row is a group and which is not.

You can call the onModelUpdated which gets called on page load and on any update to the ag-grid.

*Example:*

 onModelUpdated = (params) => {
    params.api.forEachNode((node) => {
      if (node.group) {
      console.log('Row data', node);
        } else {
//do nothing
}
    });
  }

node.group returns either true or false

Upvotes: 2

Related Questions