Ag-grid 主详细信息防止详细信息行在数据刷新时关闭
Ag-grid master detail prevent detail row from closing on data refresh
我目前正在试用 AG-Grid 主细节功能。一切正常,但我的数据将每 10 秒刷新一次。这导致详细信息在刷新数据时关闭,我必须再次打开详细信息行。
是否有任何选项可以保存打开的详细信息的状态?
Plunkr
数据设置为每5秒刷新一次,展开明细行,当数据刷新时明细将折叠。我设置了 rememberGroupStateWhenNewData : true
https://plnkr.co/edit/SgYD3vH8CXW9W9B8HD6N?p=preview
var gridOptions = {
rememberGroupStateWhenNewData:true,
columnDefs: columnDefs,
masterDetail: true,
detailCellRendererParams: {
detailGridOptions: {
rememberGroupStateWhenNewData:true,
columnDefs: [
{field: 'callId'},
{field: 'direction'},
{field: 'number'},
{field: 'duration', valueFormatter: "x.toLocaleString() + 's'"},
{field: 'switchCode'}
],
onFirstDataRendered(params) {
params.api.sizeColumnsToFit();
}
},
getDetailRowData: function (params) {
params.successCallback(params.data.callRecords);
}
},
onFirstDataRendered(params) {
params.api.sizeColumnsToFit();
}
};
你试过了吗rememberGroupStateWhenNewData?
https://www.ag-grid.com/javascript-grid-grouping/#keeping-group-state
问题是您正在使用 api.setRowData
更新数据。
https://www.ag-grid.com/javascript-grid-data-update/
This is the simplest of the update methods. When you call
api.setRowData(newData)
, the grid discards all previous selections and
filters, and completely overwrites the old data with the new. This was
the first way the grid worked and is the most 'brute force' way.
Use this method if you want to load the grid with a brand new set of
data.
此描述与您尝试执行的操作不符,因此您应该使用其他方法之一。试试 api.updateRowData(transaction)
,在演示中有很多例子。
这里有同样的问题,rememberGroupStateWhenNewData 仅适用于行分组,不适用于 master/detail 网格。
有点晚了,但这可能对其他人有帮助。如果您使用不可变数据模式,并将详细信息的刷新模式设置为 'rows',您的主数据和详细信息将更新 in-place。
查看这些链接以获取更多信息:
https://www.ag-grid.com/react-data-grid/immutable-data/
https://www.ag-grid.com/react-data-grid/master-detail-refresh/
我目前正在试用 AG-Grid 主细节功能。一切正常,但我的数据将每 10 秒刷新一次。这导致详细信息在刷新数据时关闭,我必须再次打开详细信息行。
是否有任何选项可以保存打开的详细信息的状态?
Plunkr
数据设置为每5秒刷新一次,展开明细行,当数据刷新时明细将折叠。我设置了 rememberGroupStateWhenNewData : true
https://plnkr.co/edit/SgYD3vH8CXW9W9B8HD6N?p=preview
var gridOptions = {
rememberGroupStateWhenNewData:true,
columnDefs: columnDefs,
masterDetail: true,
detailCellRendererParams: {
detailGridOptions: {
rememberGroupStateWhenNewData:true,
columnDefs: [
{field: 'callId'},
{field: 'direction'},
{field: 'number'},
{field: 'duration', valueFormatter: "x.toLocaleString() + 's'"},
{field: 'switchCode'}
],
onFirstDataRendered(params) {
params.api.sizeColumnsToFit();
}
},
getDetailRowData: function (params) {
params.successCallback(params.data.callRecords);
}
},
onFirstDataRendered(params) {
params.api.sizeColumnsToFit();
}
};
你试过了吗rememberGroupStateWhenNewData?
https://www.ag-grid.com/javascript-grid-grouping/#keeping-group-state
问题是您正在使用 api.setRowData
更新数据。
https://www.ag-grid.com/javascript-grid-data-update/
This is the simplest of the update methods. When you call
api.setRowData(newData)
, the grid discards all previous selections and filters, and completely overwrites the old data with the new. This was the first way the grid worked and is the most 'brute force' way.Use this method if you want to load the grid with a brand new set of data.
此描述与您尝试执行的操作不符,因此您应该使用其他方法之一。试试 api.updateRowData(transaction)
,在演示中有很多例子。
这里有同样的问题,rememberGroupStateWhenNewData 仅适用于行分组,不适用于 master/detail 网格。
有点晚了,但这可能对其他人有帮助。如果您使用不可变数据模式,并将详细信息的刷新模式设置为 'rows',您的主数据和详细信息将更新 in-place。
查看这些链接以获取更多信息: https://www.ag-grid.com/react-data-grid/immutable-data/ https://www.ag-grid.com/react-data-grid/master-detail-refresh/