This is a migrated thread and some comments may be shown as answers.

Nested grids, toolbars and partial views

1 Answer 307 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Justis
Top achievements
Rank 1
Justis asked on 12 Jul 2012, 07:16 PM
Greetings,

The project I am currently working on requires a grid where each row contains a detailview that contains another grid. The nested grid must contain a toolbar that renders a partial view containing a data input form. Preferably, using the built-in insert command should be avoided due to the project's specifications. When I insert string text into the toolbar's template, it renders in the correct location; however, when using Html.RenderPartial in the template it renders above both grids instead of expected location.

@{Html.Telerik().Grid<ObjectType>()
    .Name("Grid")
    .DataBinding(bind => bind.Ajax().Select("_GetMembers", "Controller"))
    .Columns(col =>
    {
        col.Bound(o => o.MemberID);
        col.Bound(o => o.Member);
    })
    .DetailView(detail => detail.ClientTemplate(
        Html.Telerik().Grid<ObjectType2>()
            .Name("DetailGrid_<#= MemberID #>")
            .DataKeys(keys => keys.Add(o => o.Member2ID))
            .ToolBar(tool => tool.Template(() => Html.RenderPartial("Detail_Grid_Toolbar")))
            .DataBinding(bind => bind.Ajax()
                .Select("_GetDetails", "Controller", new { id2 = "<#= MemberID #>" })
                .Delete("_DeleteDetails", "Controller")
            )
            .Columns(col =>
            {
                col.Bound(o => o.Member2ID);
                col.Bound(o => o.Member2);
            })
            .ToHtmlString()
    ))
    .Render();
}

Is there a way to make this work? I have some doubts since my experiences with Html.RenderPartial and AJAX-bound nested grids hasn't yielded very many positive results, but I feel like I am missing something that should be fairly straight-forward.

Any advice and/or suggestions is greatly appreciated.

Regards,
J

1 Answer, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 17 Jul 2012, 12:15 PM
Hi,

You can use the Html.Partial helper in a text tag for the template in order to render the partial view in the toolbar and not directly into the view e.g.

.ToolBar(tool => tool.Template(@<text> @Html.Partial("Detail_Grid_Toolbar")</text> ))

Regards,
Daniel
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
Tags
Grid
Asked by
Justis
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or