Is the following format possible with ag-grid:
- Merged header with blank name
- Merged header with name in 2 lines ("Original Values")
- Parent header centered ("Header with children")
Is the following format possible with ag-grid:
I'm struggling with this for quite a while, but i can not find a good solution. Anyway i figured out a solution (at least for my self).
In my case, the headers are dynamic. Only some headers have children.
Here is the solution:
In your columnDefs, use 'headerClass'
const rowSpanClass = ..... // This is calculated base on the data you have or set it static
columnDefs = {
....
....
headerClass: rowSpanClass, // In my case, if it is 2 rowspan, i call it 'header-row-span-2'
......
}
Apply style on the custom header class
.header-row-span-2 { position: fixed; top: 50px; height: 100px; }
.header-row-span-3 {
position: fixed;
top: 100px;
height: 150px;
}
The value of 'top' and 'height' need to be changed accordingly (ag-grid header height is 50px by default)
Just to share. I think this is not possible using the headers in ag-grid. So, instead, I set the headerheight to 0 and use the row cells to achieve the header format.
I know it is been too late for the answer but just to help another people know it.
Yes, it is possible with an updated version of ag-grid, please check it out.
var columnDefs = [ {
headerName: 'Athlete Details',
children: [
{
headerName: 'Athlete',
field: 'athlete',
width: 150,
suppressSizeToFit: true,
enableRowGroup: true,
rowGroupIndex: 0,
},
{
headerName: 'Age',
field: 'age',
width: 90,
minwidth: 75,
maxWidth: 100,
enableRowGroup: true,
}]
}];