自定义 AG Grid 中的默认聚合函数名称

问题描述 投票:0回答:2

在AG Grid中,当应用行分组时,列菜单中有一个“值聚合”选项。此选项有一个子菜单,列出了可用的聚合函数(“sum”、“min”、“max”等)以及网格上定义的自定义聚合函数。

此处显示的默认聚合函数为小写且缩写。我希望将它们放在标题中而不是缩写。

值聚合(默认) 价值聚合(必填)
平均 平均
首先 第一
最后 最后

首选项或 API 中是否有任何可用的内容可以实现此目的?

javascript reactjs ag-grid
2个回答
0
投票

这可以通过定义自定义聚合函数

来实现

在本例中,我只是传递原始聚合函数,但您也可以定义自己的自定义函数。

const gridOptions = {
  // ...Other grid options
  aggFuncs: {
    Average: (params) => params.api.aggFuncService.aggFuncsMap.avg(params),
    Count: (params) => params.api.aggFuncService.aggFuncsMap.count(params),
    First: (params) => params.api.aggFuncService.aggFuncsMap.first(params),
    Last: (params) => params.api.aggFuncService.aggFuncsMap.last(params),
  }
};

这是一个 Plunker 示例:

https://plnkr.co/edit/GnC6spz2y516GW4b


0
投票
const aggFuncs = useMemo(() => {
    return {
      'getCompletion': completionAggFunc

    };
  }, []);

 function completionAggFunc(nodes: any) {
    let completed = 0;
    let total = 0;
    nodes.forEach((value: any) => {
      total++;
      if (value === '100' || value === 100) {
        completed++;
      }
    });

    return Math.round((completed / total) * 100);
  }

<AgGridReact
    columnDefs={columnDefs}
    aggFuncs={aggFuncs}
/>
© www.soinside.com 2019 - 2024. All rights reserved.