I have a question. Restricted Merging

Posted by: ahehheh123 on 14 April 2024, 4:25 pm EST

  • Posted 14 April 2024, 4:25 pm EST - Updated 14 April 2024, 4:32 pm EST

    https://developer.mescius.com/wijmo/demos/Grid/Merging/RestrictedMerging/react

    I hope the merging is not applied to the header part in the picture below. Please teach me the way.

  • Posted 15 April 2024, 10:33 pm EST

    Hello,

    Based on our understanding, it appears that you want to apply merging only to data cells and not to ColumnHeaders. If that’s the case, you can add a condition in the getMergedRange method of the custom merge manager using CellType enums. Please refer to the CellType enum in our API documentation for more information:

    class RestrictedMergeManager extends wjGrid.MergeManager {
        getMergedRange(p, r, c, clip = true) {
            //
            // create basic cell range
            var rng = null;
            if (p.cellType === wjGrid.CellType.Cell) {		//Update Condition Here
                //
                // start with single cell
                rng = new wjGrid.CellRange(r, c);
                var pcol = c > 0 ? c - 1 : c;
                //
                // get reference values to use for merging
                var val = p.getCellData(r, c, false);
                var pval = p.getCellData(r, pcol, false);
                //
                // expand up
                while (rng.row > 0 &&
                    p.getCellData(rng.row - 1, c, false) == val &&
                    p.getCellData(rng.row - 1, pcol, false) == pval) {
                    rng.row--;
                }
                //
                // expand down
                while (rng.row2 < p.rows.length - 1 &&
                    p.getCellData(rng.row2 + 1, c, false) == val &&
                    p.getCellData(rng.row2 + 1, pcol, false) == pval) {
                    rng.row2++;
                }
                //
                // don't bother with single-cell ranges
                if (rng.isSingleCell) {
                    rng = null;
                }
                //
                // done
                return rng;
            }
            return rng;
        }
    }

    API link: https://developer.mescius.com/wijmo/api/enums/Wijmo_Grid.Celltype.html

    Similarly, you can apply the merging to a specific region by adding conditions using CellType.

    Regards

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels