Merge header cells

Posted by: bmakhlin on 17 October 2018, 2:52 am EST

    • Post Options:
    • Link

    Posted 17 October 2018, 2:52 am EST - Updated 3 October 2022, 11:20 am EST

    Hi, I am trying to merge column header cells and I can’t get cells I want to merge.

    Attached are the screenshots showing the merge results.

    I have flex grid with four columns and two column header rows. I need to merge cells in column 0 and column 1 with column header row 0 and row 1 like so.

    
    |Existing Product        | P1             | P2             |   
    |                                    |[x] 34/100 | [x] 72/200| 
      --------------------------------------------------
    |P3           | [x] 3/10   |  [x]             | [ ]
    |P4           |[ ] 30/100 |  [ ]             | [ ]
    
    

    Below are the result of the attempts to merge:

    Doing nothing produces grid with four column header cells that have ‘Existing Product’ text. See UnmergedCells.JPG

    If I merge column header row 0 and row 1 by implementing the following code

    
     this.flexGrid.allowMerging = wjcGrid.AllowMerging.All;
    this.flexGrid.columnHeaders.rows[0].allowMerging = true;
    this.flexGrid.columnHeaders.rows[1].allowMerging = true;
    
    

    I get Grid in MergedRows.JPG.

    If I merge column header row 0, row 1, column 0 and/or Column 1 by implementing the following code

    
    this.flexGrid.allowMerging = wjcGrid.AllowMerging.All;
    this.flexGrid.columnHeaders.columns[0].allowMerging = true;
    this.flexGrid.columnHeaders.columns[1].allowMerging = true;
    this.flexGrid.columnHeaders.rows[0].allowMerging = true;
    this.flexGrid.columnHeaders.rows[1].allowMerging = true;
    
    

    I get Grid in MergedRowAndColumns.JPG

    As you see last merge removes P4 row from the grid and does not give me expected result.

    I also tried the following without success:

    
    this.flexGrid.columns[0].allowMerging = false;
    this.flexGrid.columns[1].allowMerging = false;
    
    

    Please let me know what I need to do to merge column header cells.

    Do I need to user Merge Manager for this?

    thank you

  • Posted 17 October 2018, 8:09 pm EST

    Hi,

    The default MergeManager only merges either rows or columns, to merge both rows and columns, you need to implement custom MergeManager.

    Please refer to the following sample which demonstrates the same:

    https://demos.wijmo.com/5/SampleExplorer/SampleExplorer/Sample/CustomMerging

    ~Sharad

Need extra support?

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

Learn More

Forum Channels