0

I have recently started diving into all of the nuances of ag grid (version 31.3.2) and its pretty particular order of operations it expects things to happen in and im running into an issue where using gridApi.setGridOption('columnDefs', newColumnDefs); does not end up doing anything.

My setup is seemingly simple. i have an angular component wrapping ag grid that takes an input called 'isCompact' that is true or false and another signal called isGridReady that gets set when the grid is ready. I have an effect on that input that attempts to set the row height to a standard or compact row height (working 100% fine) and also supplies some classes that modify how the cells should look in the different modes:


constructor() {
  effect(() => {
    this.reactToIsCompactChange();
  }
}

private reactToIsCompactChange(): void {
    if (this.isGridReady()) {
      this.gridApi.setGridOption('rowHeight', this.isCompact() ? this.COMPACT_HEIGHT : this.STANDARD_HEIGHT);
      const compactDefs = this.gridApi.getColumnDefs().map((col) => {
        if (this.isColDef(col)) { // type guard to filiter out the ColGroupDefs
            col.cellClass = this.isCompact() ? ['my-compact-classes'] : ['my-standard-classes'];
        }
        return col;
      });
      this.gridApi.setGridOption('columnDefs', compactDefs);
    }
  }

when toggling isCompact between true and false i see the row height changing but the classes are not getting applied to any of my cells and the classes are not showing up on the cells when i inspect them.

is this an incorrect way of applying new column definitions and expecting to see the changes happening? Ive tried all of the gridApi methods that "refresh" the view (refreshClientSideRowModel, refreshCells, refreshHeader) as well but nothing works.

There is no way this is a timing issue because i am toggling this boolean input well after the grid is ready and just waiting there after already being given valid initialState, columnDefs, and rowData.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.