Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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://imgur.com/a/mJoM5tw

like image 387
Troyd Avatar asked Dec 07 '22 12:12

Troyd


1 Answers

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'.

like image 177
Pratik Bhat Avatar answered Dec 28 '22 05:12

Pratik Bhat