angulartypescriptag-grid

Ag-grid: How to change define column headerName when using AggFunc?


For a given column definition, when using aggFunc the headerName appears in format func(string) - I just want the header to display the string I define. This behaviour does not exist when AggFunc is null.

const  columnDef: any = {

    headerName: 'Test',
    field: date,
    suppressMenu: true,
    width: 80,
    editable: true,
    lockPosition: true,
    type: 'numericColumn',
    aggFunc: function(data) {

      let sum = 0;
      data.forEach( function(value) {
        if (value) {
            sum = sum + parseFloat(value);
          }
      } );
      if (!sum) { return null; }

      return sum.toFixed(2);
    },
}

The headerName should say "test", but will instead show func(test).

https://i.sstatic.net/xHPMh.jpg


Solution

  • You need to mark this property as true in your gridOptions.

    suppressAggFuncInHeader : true;
    

    As per docs-

    When true, column headers won't include the aggFunc, eg 'sum(Bank Balance)' will just be 'Bank Balance'.