Thank you Manish. After changing to push Row instead of GroupRow. It is working.
The issue I am still getting is:
- I need my columnheaders to merge both vertical and horizontal
- Any other cells not columnheaders to merge horizontal only.
I achieve this by setting the s.allowMerging = wjGrid.AllowMerging.All;
then each row that need merging by:
for (let i = 0; i < s.rows.length; i++) {
s.rows[i].allowMerging = true;
}
s.columnHeaders.rows[0].allowMerging = true
s.columnHeaders.rows[1].allowMerging = true
s.columnHeaders.rows[2].allowMerging = true
s.columnHeaders.rows[3].allowMerging = true
This will merge horizontal fine. But columnheader need both horizontal and vertical merging, so I add:
for (let i = 0; i < s.columns.length; i++) {
s.columns[i].allowMerging = true;
}
When I do this, all rows, all cells are merging both horizontal and vertical when cell contains same value. I only need header to merge horizontal & vertical.
I saw your example of custom merger. I have tried it:
mergeHeaders(grid: wjGrid.FlexGrid, range: wjGrid.CellRange): void {
let mm = new wjGrid.MergeManager(grid);
mm.getMergedRange = function(panel, r, c) {
if (panel.cellType === wjGrid.CellType.ColumnHeader) {
if (r >= 0 && range.contains(r, c)) {
return range;
}
}
return null;
};
grid.mergeManager = mm;
}
and I call it in loadedRows event:
this.mergeHeaders(s, new wjGrid.CellRange(0,2,2,8));
this.mergeHeaders(s, new wjGrid.CellRange(0,9,0,15));
this.mergeHeaders(s, new wjGrid.CellRange(1,9,1,15));
this.mergeHeaders(s, new wjGrid.CellRange(0,16,0,22));
this.mergeHeaders(s, new wjGrid.CellRange(1,16,1,22));
this.mergeHeaders(s, new wjGrid.CellRange(0,23,1,s.columns.length - 1));
The weird thing is that, it breaks all cell merging I had before, but this is normal because I am applying custom merging. What weird is that I call mergeHeader() 6 times, it will merge the last call only, which is this.mergeHeaders(s, new wjGrid.CellRange(0,23,1,s.columns.length - 1)) and break all others. How can I combine multi ranges into 1 single range and then call mergeHeader()?
Thank you sir very much