Grid cell merge in unbound using CellContentRenderFragment

Posted by: ehh on 15 December 2021, 9:08 pm EST

  • Posted 15 December 2021, 9:08 pm EST

    Hello,
    I have a problem getting my cells to merge.
    Im using the unbound grid and custom renderfragment in my cell fractory to display the cells. I need the renderfragment in my own solution to add some buttons, to specific cells if needed.

    The grid without cell merging.


    When I enable cell merging, all the cells get merged as shown below.


    I think it could have something to do with the use of a class when setting the values of the grid, since the grid then sees the name of the class as the value of the cell. This can be seen if I disable the cellfactory as shown below,


    I have attached the example code use to demostrate my issue.
    FlexGridCellMerge.zip

    Best Regards,
    Emil
  • Marked as Answer

    Replied 16 December 2021, 2:59 pm EST

    Hi Emil,
    Yes, your assumption is correct. The cells are merging because of the Cell Value that is object.
    For merging the cells based on their values, we need to handle the MergeManager and define the CustomMerge class same as we done for the CellFactory.

    Please refer to the following code snippet and the attached sample.

    <FlexGrid @ref="grid"
    MergeManager ="@mergeManager">
    </FlexGrid>
    GridMergeManager mergeManager = new CustomGridMerging();
    public class CustomGridMerging : GridMergeManager
    {
    public override GridCellRange GetMergedRange(GridCellType cellType,GridCellRange range)
    {
    FlexGrid Grid = this.Grid;
    if(this.AllowMerging == GridAllowMerging.Cells && cellType== GridCellType.Cell)
    {
    //code here for merging
    return range;
    }

    return base.GetMergedRange(cellType, range);
    }
    }

    Regards,
    Manish Gupta

    FlexGrid_Merging.zip
Need extra support?

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

Learn More

Forum Channels