I'm stacked to add Custom columns dynamically in ag-grid. I have tried following approach.
additionalCol = { field:'SOME RANDOM', headerName: 'SOME RANDOM' };
$scope.gridOptions.columnApi.addValueColumn(additionalCol);
I have also tried
$scope.columns.push(additionalCol);
$scope.gridOptions.api.refreshView();
but didn't get success. I even tried to add columns that exist in Data but failed. Below is Image for what I am trying.
As shown in image "% dev" is Custom column which I need to add dynamically with dynamically calculated values.
Try this:
var columnDefs = $scope.gridOptions.columnDefs;
columnDefs.push({ field:'SOME RANDOM', headerName: 'SOME RANDOM'});
$scope.gridOptions.api.setColumnDefs(columnDefs);