Skip to content

Migration from older GridMvc #421

@ParaSwarm

Description

@ParaSwarm

Hello there. I am migrating a project from an older GridMvc for MVC 4-ish, to .NET Core and GridMvcCore.

The original developer created custom helpers to render the grid in a certain way. They are simple, but the problem is that the CellRenderer and HeaderRenderer properties of IGridColumn don't exist in the newer library.

What is the correct way to migrate these lines that would render the cells and headers for each column? Thank you very much.

@{
    void RenderGridBody()
    {
        if (!Model.ItemsToDisplay.Any())
        {
            <tr class="grid-empty-text">
                <td colspan="@Model.Columns.Count()">
                    @Model.EmptyGridText
                </td>
            </tr>
        }
        else
        {
            foreach (object item in Model.ItemsToDisplay)
            {
                <tr class="grid-row @Model.GetRowCssClasses(item)">
                    @foreach (IGridColumn column in Model.Columns)
                    {
                        @column.CellRenderer.Render(column, column.GetCell(item)) <-- offender #1 - CellRenderer
                    }
                </tr>
            }
        }
    }
    void RenderGridHeader()
    {
        <tr>
            @foreach (IGridColumn column in Model.Columns)
            {
                @column.HeaderRenderer.Render(column) <-- offender #2 - HeaderRenderer
            }
        </tr>
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions