【发布时间】:2020-08-31 06:52:53
【问题描述】:
我在 ag-grid 中有数据透视表,我已启用 gridOptions.pivotColumnGroupTotals = after。
但默认设置是为组总计折叠其他值。
有没有办法让这个分组的总开始默认打开?
理想情况下,我可以指定默认打开哪一列。
谢谢!
【问题讨论】:
我在 ag-grid 中有数据透视表,我已启用 gridOptions.pivotColumnGroupTotals = after。
但默认设置是为组总计折叠其他值。
有没有办法让这个分组的总开始默认打开?
理想情况下,我可以指定默认打开哪一列。
谢谢!
【问题讨论】:
使用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!';
}
}
]
},
【讨论】:
openByDefault,您需要像在您的剪辑中一样单独指定您的列 - 这不是枢轴结构的情况。我已经通过在打开网格后调用网格 api 提供的一些方法来实现它 - 但我认为这还不是一个很好的解决方案。