FlexGrid with freezed Columns / new row template

Posted by: daniel.koffler on 29 March 2023, 12:07 am EST

    • Post Options:
    • Link

    Posted 29 March 2023, 12:07 am EST - Updated 29 March 2023, 12:12 am EST


    If a FlexGrid has freezed columns defined the new row template is shown twice. (1x inside freezed columns, 1x for regular columns) How can I get rid of the 2nd row template (refer to screenshot)

    Thank you


  • Posted 30 March 2023, 3:41 pm EST

    Hello Daniel,

    To implement the above requirement, we may use the GridCellFactory class which is used to create every cell which is rendered on the FlexGrid.

    You may overwrite the “GetCellContentRenderFragment” method of the GridCellFactory Class, check if the RowPosition is Top, then you could render empty string in the cell next to the frozen Column.

    Kindly refer to the following code snippet and the attached Sample:

        public class MyCellFactory : GridCellFactory
            public override RenderFragment GetCellContentRenderFragment(GridCellType cellType, GridCellRange range)
                if (cellType == GridCellType.Cell && range.Column == grid.FrozenColumns 
                    && grid.NewRowPosition == GridNewRowPosition.Top && range.Row == 0)
                    // Render a Fragment with Empty String
                    RenderFragment rf3 = (builder) =>
                       builder.OpenElement(0, "text");
                       builder.AddContent(1, String.Empty);
                    return rf3;
                    return base.GetCellContentRenderFragment(cellType, range);

    Similary you could check if the NewRowPosition is Bottom, then you could render Empty String in the Bottom Row next to the Frozen Column.

    GetCellContentRenderFragment method: https://www.grapecity.com/componentone/docs/blazor/online-blazor/C1.Blazor.Grid~C1.Blazor.Grid.GridCellFactory~GetCellContentRenderFragment(GridCellType,GridCellRange).html



    Sample: FlexGrid_FreezedColumns_NewRowTemplate.zip

  • Posted 5 April 2023, 5:06 am EST

    Works perfectly - thanks!

Need extra support?

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

Learn More

Forum Channels