Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Edit headers in Ag-grid

Ag-grid gives support to edit column cells. How do I edit column headers in ag-grid?

like image 675
jgr0 Avatar asked Aug 04 '26 23:08

jgr0


1 Answers

It's there on documentations itself. Link: Updating Column Definitions

After the grid has been initialised it may be necessary to update the column definition. It is important to understand that when a column is created it is assigned a copy of the column definition defined in the GridOptions. For this reason it is necessary to obtain the column definition directly from the column.

The following example shows how to update a column header name after the grid has been initialised. As we want to update the header name immediately we explicitly invoke refreshHeader() via the Grid API.

// get a reference to the column
var col = gridOptions.columnApi.getColumn("colId");

// obtain the column definition from the column
var colDef = col.getColDef();

// update the header name
colDef.headerName = "New Header";

// the column is now updated. to reflect the header change, get the grid refresh the header
gridOptions.api.refreshHeader();
like image 93
Paritosh Avatar answered Aug 07 '26 12:08

Paritosh