【问题标题】:ag-grid pivot total columns open by default默认情况下打开 ag-grid 透视总列
【发布时间】:2020-08-31 06:52:53
【问题描述】:

我在 ag-grid 中有数据透视表,我已启用 gridOptions.pivotColumnGroupTotals = after。 但默认设置是为组总计折叠其他值。

有没有办法让这个分组的总开始默认打开?

理想情况下,我可以指定默认打开哪一列。

谢谢!

【问题讨论】:

    标签: pivot ag-grid


    【解决方案1】:

    使用openByDefault 属性,同时声明您的列组对象,导致这些组默认显示为打开..

    这里是一个示例代码 sn-p。

        //column group 'Performance'
        headerName: 'Performance',
        groupId: 'performance',
        openByDefault : true, //this tells AG grid to expand the children by default
        children: [
            {
                headerName: "Bank Balance", field: "bankBalance", width: 180, editable: true,
                filter: 'winningsFilter',
                valueFormatter: currencyFormatter,
                type: 'numericColumn',
                cellClassRules: {
                    'currencyCell': 'typeof x == "number"'
                },
                enableValue: true,
                // colId: 'sf',
                // valueGetter: '55',
                // aggFunc: 'sum',
                icons: {
                    sortAscending: '<i class="fa fa-sort-amount-up"/>',
                    sortDescending: '<i class="fa fa-sort-amount-down"/>'
                }
            },
            {
                colId: 'extraInfo1',
                headerName: "Extra Info 1", columnGroupShow: 'open', width: 150, editable: false, filter: false,
                sortable: false, suppressMenu: true, cellStyle: { "text-align": "right" },
                cellRenderer: function() {
                    return 'Abra...';
                }
            },
            {
                colId: 'extraInfo2',
                headerName: "Extra Info 2", columnGroupShow: 'open', width: 150, editable: false, filter: false,
                sortable: false, suppressMenu: true, cellStyle: { "text-align": "left" },
                cellRenderer: function() {
                    return '...cadabra!';
                }
            }
        ]
    },
    

    【讨论】:

    • 嗨,Sandeep,感谢您的回答,但不幸的是,这对我的情况不起作用。为了使用openByDefault,您需要像在您的剪辑中一样单独指定您的列 - 这不是枢轴结构的情况。我已经通过在打开网格后调用网格 api 提供的一些方法来实现它 - 但我认为这还不是一个很好的解决方案。
    猜你喜欢
    • 2021-08-30
    • 1970-01-01
    • 2016-02-28
    • 1970-01-01
    • 2021-08-21
    • 1970-01-01
    • 1970-01-01
    • 2012-05-03
    • 1970-01-01
    相关资源
    最近更新 更多