ag-grid: setColumnDefs does not repaint the grid

I’m submitting a … (check one with “x”)

[x] bug report => see 'Providing a Reproducible Scenario'
[] feature request => do not use Github for feature requests, see 'Customers of ag-Grid'
[] support request => see 'Requesting Community Support'

We are having a grid with dynamic group (i.e. rowGroup can be programmatically changed). To do that, we used setColumDefs to rebuild the grid.

In version 19.0.0 everything works fine.

Current behavior

setColumnDefs doesn’t repaint the grid (or maybe it does, but not applying the new columnDefs to the view)

Expected behavior

setColumnDefs repaints the grid with new columnDefs

Please tell us about your environment: Windows, npm

  • ag-Grid version: 19.1.2
  • Browser: Chrome
  • Language: [TypeScript]

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 7
  • Comments: 18 (6 by maintainers)

Most upvoted comments

this.agGrid.api.setColumnDefs([]); this.agGrid.api.setColumnDefs(this.colDefs);

That is the answer! setColumnDefs doesn’t detect the changes of some Column Properties, like “hide”, “rowGroupIndex”… refreshCells()… are not the answer, just empty the whole array before update it. thanks @gustavomick

@makinggoodsoftware noticed that this ticket is closed but I have a similar issue using “ag-grid-enterprise”: “^20.1.0” basically if I reorder the columns using

   this.agGrid.api.setColumnDefs(this.colDefs);
   this.agGrid.api.setServerSideDatasource(this.datasource);

is not changing grid column order, if I do

   this.agGrid.api.setColumnDefs([]);
   this.agGrid.api.setColumnDefs(this.colDefs);
   this.agGrid.api.setServerSideDatasource(this.datasource);

is indeed ordering columns as I expect, but is also calling getRows 3 times, thus hitting 3 times server. could you give me any tip related to this. thanks

If you’re only looking to hide/show columns, you can use setColumnVisible/setColumnsVisible instead of emptying the columnDefs array: columnApi.setColumnVisible('field_name', false);

Hi,

Sorry for that, as mentioned above, you should find a final solution in our v20.x release (eta 4/5 weeks)

Thanks

I noticed this week the same breaking change.

Set new column definition by setColumnDefs doesn’t work anymore

This change should be reverted or at least provide a parameter for the method setColumnDefs(onlyDelta = false).