I need to add some columns to my Ag-grid in 2 cases. Other cases i just need base columns.
So in constructor I declare my grid like this :
this.gridOption.columnDefs = [
{
headerName: 'Admission date',
field: 'admissionPlannedDate',
cellRendererFramework: DateCellRendererComponent,
cellRendererParams: (params) => {
return (params.data.admissionPlannedDate ? {dateFormat: 'dd.MM.yyyy - HH:mm'} : {dateFormat: ' '});
},
cellStyle: function (params) {
return (params.data.admissionPlannedDate < new Date() ? {color: 'red'} : {});
}
},
{
headerName: 'Lastname',
field: 'lastName',
cellStyle: function (params) {
return (params.data.edsId === null ? {color: 'orange'} : {});
}
},
},
{
headerName: 'Sex',
field: 'sex',
},
{
headerName: 'Birthdate',
field: 'birthDate',
cellRendererFramework: DateCellRendererComponent,
cellRendererParams: (params) => {
return (params.data.birthDate ? {dateFormat: 'dd.MM.yyyy'} : {dateFormat: ' '});
},
},
{
headerName: 'Localisation',
field: 'localisation',
}
];
Then In my ngOnInit, in some conditions i need do add columns to my ag-grid.
I tried this following :
this.gridOption.columnDefs.push(
{
headerName: 'Block',
field: 'block',
}, {
headerName: 'SDS/Hosp',
field: 'sdsOrHosp'
}
);
console.log(this.gridOption); //I see the new columns here so the add worked but i don't see them visual in my grid
also tried
this.gridOption.columnDefs.push({ headerName: 'Bloc', field:'block'});
this.gridOption.columnDefs.push({ headerName: 'SDS/Hosp', field:'SDSorHosp'});
Someone has an idea ? thanks