Ag-grid:使用AggFunc时如何更改定义列headerName? [英] Ag-grid: How to change define column headerName when using AggFunc?

查看:56
本文介绍了Ag-grid:使用AggFunc时如何更改定义列headerName?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于给定的列定义,当使用aggFunc时,headerName以func(string)格式显示-我只希望标题显示我定义的字符串.当AggFunc为null时,此行为不存在.

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);
    },
}

headerName应该显示"test",但将显示func(test).

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

https://imgur.com/a/mJoM5tw

推荐答案

您需要在 gridOptions 中将此属性标记为true.

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

suppressAggFuncInHeader : true;

根据文档-

为true时,列标题将不包含aggFunc,例如'sum(Bank余额)就是银行余额".

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

这篇关于Ag-grid:使用AggFunc时如何更改定义列headerName?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆