user3722622
user3722622

Reputation:

AG-Grid - Apply Style to Whole Column Dynamically?

I need to apply a background color to a whole column when a custom editor is opened on a cell. I am using:

const col = this.params.column.getColDef();
col.cellStyle = { 'background-color': 'yellow' };

But this is only affecting the cell currently being edited, and not the whole column, which is what I need. I'm using Angular 4+

Upvotes: 2

Views: 7954

Answers (1)

Alberto Gutierrez
Alberto Gutierrez

Reputation: 1588

You need to add this to your colDef for the column, as opposed to setting it dynamically, note that this property can also be a callback so you can dynamically adjust your styling.

https://www.ag-grid.com/javascript-grid-cell-styles/

https://www.ag-grid.com/javascript-grid-cell-editing/#editing-api

Upvotes: 1

Related Questions