We have a table with approx. 5000 rows and 50 cols. Some cells should merged. After ajax and
hot.loadData()
I start a function that build the mergeCells-array. I can merge one col, but after try to merge two cols the browser runs into anr.
Here the code snippet for generating array and start merging.
function mergeCells(hot, groupby, fields) {
var Nrs = {};
let lastNr, mergeCells = [];
hot.getDataAtProp(groupby).forEach(function (g, i) {
if (lastNr === g) {
if (!!Nrs[g]) {
Nrs[g].rowspan++;
} else {
Nrs[g] = {
"row": i - 1,
"rowspan": 2
};
}
} else lastNr = g;
});
// convert "a,b" into [1,2]
const cols = fields.split(',').map(function (prop) {
return hot.propToCol(prop);
});
cols.forEach(function (col) {
Object.keys(Nrs).forEach(function (h) {
mergeCells.push({
row: Nrs[h].row,
col: col,
rowspan: Nrs[h].rowspan,
colspan: 1
});
});
});
hot.updateSettings({
mergeCells: mergeCells,
});
}
Call:
mergeCells(hot, "group","group,firstname,city,address") {
How can I avoid the anr?