Hello,
In our implementation of the Grid (Vanilla JS), we handle display variants, with which the users can choose which columns are displayed and in which order. There are approximately 150 columns available.
So when switching from one variant to another, we remove all columns from the 1st variant and add all the columns of the 2nd one.
This switch is not very performant at the moment. And we noticed that the great majority of the time is consumed by the removal operation.
I built an simple example to demonstrate the issue. It is a grid with 150 columns and 10 lines. You will see that the "Remove all columns" action takes roughly 10s, when the "Reset columns" is virtually immediate.
import { Grid } from '../../build/grid.module.js?450896';
import shared from '../_shared/shared.module.js?450896';
var oGrid = new Grid({
appendTo : 'container',
features : {
group : false
},
columns : generateColumns(),
data : generateData(),
tbar: [
{
type: "button",
key: "removeColumns",
text: "Remove all columns",
onAction : () => {
oGrid.columns.remove(aAllRecords);
}
},
{
type:"button",
key: "addColumns",
text: "Reset Columns",
onAction : () => {
oGrid.columns.add(aAllRecords);
}
}
]
});
var aAllRecords = oGrid.columns.allRecords.slice();
aAllRecords.shift();
function generateColumns() {
var aColumns = [];
for (var i = 0; i < 150; i++) {
aColumns.push({
text:"Column" + i,
field: "column" + i
});
}
return aColumns;
}
function generateData() {
var aData = [];
for (var i = 0; i < 10; i++) {
var mData = {
id: "id" + i
};
for (var j = 0; j < 150; j++) {
mData["column" + j] = "Data" + i + "Column" + j;
}
aData.push(mData);
}
return aData;
}
So can you please work on increasing the performance of the "remove" action?
Thanks.
Best regards,