【问题标题】:AgGrid multigroup countAgGrid 多组计数
【发布时间】:2020-03-13 14:18:25
【问题描述】:

在 AgGrid multi-group 列场景中,如何显示第一列有第二列的计数?

在下面的示例中,美国在其中显示 (1109) 行,但我想显示 (7),其中的年数。 所以它应该显示United States (7)。如何实现这个?

【问题讨论】:

    标签: javascript angularjs ag-grid


    【解决方案1】:

    似乎在组设置中定义自定义innerRenderer 可能是正确的解决方案。

    1. gridOptions 中添加autoGroupColumnDef 属性作为自动分组列使用的配置
    var gridOptions = {
        autoGroupColumnDef: {
            width: 200,
            headerName: 'Group', //header name of the group
            cellRenderer: 'agGroupCellRenderer', //default cell renderer for groupings
            // provide extra params to the cellRenderer
            cellRendererParams: {
                suppressCount: true, // turn off the row count (in order to skip default stack counting)
                innerRenderer: customInnerRenderer, //our inner renderer in charge of child nodes counting
            }
        },
        //other settings
        columnDefs: columnDefs,
        animateRows: true,
        enableRangeSelection: true,
        rowData: null
    };
    
    
    1. 定义将处理计数显示的customInnerRenderer
    function customInnerRenderer(params){
        //this verification is necessary, otherwise the grid will brake down
        //when last level without grouping will be reached (if exists)
        if (params.node.group) {
            var label = params.value ? params.value : '-';
            return label + ' (' + params.node.childrenAfterFilter.length  + ')';
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-12
      • 1970-01-01
      • 2018-10-12
      • 1970-01-01
      • 2022-11-18
      • 2020-07-26
      • 1970-01-01
      • 2019-03-01
      相关资源
      最近更新 更多