gpt4 book ai didi

javascript - Ag-grid-Enterprise 使用按钮展开/折叠所有行?非常慢的崩溃 FF 和 Edge

转载 作者:行者123 更新时间:2023-12-03 20:03:15 24 4
gpt4 key购买 nike

我创建了一个按钮来展开 中的所有行农业网格 (企业)在网格中有 150 行。它在 Chrome 中运行良好,但在最新的 FF 和 Edge 中显示警告,称该网页使您的浏览器变慢。 有没有更好的方法来扩展所有行?大约需要 10-15 秒

HTML

<button (click)="expandAll(expand)">Expand/Collapse</button>  

JavaScript
this.columnDefs = [
{
headerName: "",
field: "",
cellRenderer: "group",// for rendering cell
suppressMenu: true,
suppressSorting: true
}
]
// This is how I am creating fullrow width
this.gridOptions = <GridOptions>{
isFullWidthCell: function (rowNode) {
var rowIsNestedRow = rowNode.flower;
return rowIsNestedRow;
},
fullWidthCellRendererFramework: AgGridInventorRowComponent,
doesDataFlower: function (dataItem) {
return true;
}
public expandAll(value:boolean) {
if(value) {
this.gridOptions.api.forEachNode((node) =>{
node.setExpanded(true);
});
} else {
this.gridOptions.api.forEachNode((node) =>{
node.setExpanded(false);
});
}
}

enter image description here

最佳答案

根据文档:

Calling node.setExpanded() causes the grid to get redrawn. If you have many nodes you want to expand, then it is best to set node.expanded=true directly, and then call api.onGroupExpandedOrCollapsed() when finished to get the grid to redraw the grid again just once.



所以我修改了我的代码,如下所示:
this.gridOptions.api.forEachNode(node => {
node.expanded = true;
});
this.gridOptions.api.onGroupExpandedOrCollapsed();

Ag-gridDocumentation page Group Api 内部

关于javascript - Ag-grid-Enterprise 使用按钮展开/折叠所有行?非常慢的崩溃 FF 和 Edge,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45968308/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com