0

Can anyone please provide me the similar solution using kendo MVC as in the below link?

Creating 2 child kendo grids at the same level

Thanks!

Alice
  • 3
  • 1

1 Answers1

0

Use the client template features. So on your grid:

@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.EmployeeViewModel>()
    .Name("grid")
    .Columns(columns =>
    {
        columns.Bound(e => e.FirstName).Width(130);
        columns.Bound(e => e.LastName).Width(130);
        columns.Bound(e => e.Country).Width(130);
        columns.Bound(e => e.City).Width(110);
        columns.Bound(e => e.Title);

    })               
    .Sortable()
    .Pageable()
    .Scrollable()
    >> refer to the template
    .ClientDetailTemplateId("template")
... etc

Then make the template with the 2 grids:

<script id="template" type="text/kendo-tmpl">
    @(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.OrderViewModel>()
            .Name("grid_#=EmployeeID#") // template expression, to be evaluated in the master context
            .Columns(columns =>
            {
                columns.Bound(o => o.OrderID).Width(110);
                columns.Bound(o => o.ShipCountry).Width(150);
                columns.Bound(o => o.ShipAddress).ClientTemplate("\\#= ShipAddress \\#"); // escaped template expression, to be evaluated in the child/detail context
                columns.Bound(o => o.ShipName).Width(300);
            })
            .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(10)
                .Read(read => read.Action("HierarchyBinding_Orders", "Grid", new { employeeID = "#=EmployeeID#" }))
            )
            .Pageable()
            .Sortable()
            .ToClientTemplate()
    )

    @(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.OrderViewModel>()
        .Name("grid2_#=EmployeeID#") // template expression, to be evaluated in the master context
        .Columns(columns =>
        {
            columns.Bound(o => o.OrderID).Width(110);
            columns.Bound(o => o.ShipCountry).Width(150);
            columns.Bound(o => o.ShipAddress).ClientTemplate("\\#= ShipAddress \\#"); // escaped template expression, to be evaluated in the child/detail context
            columns.Bound(o => o.ShipName).Width(300);
        })
        .DataSource(dataSource => dataSource
            .Ajax()
            .PageSize(10)
            .Read(read => read.Action("HierarchyBinding_Orders", "Grid", new { employeeID = "#=EmployeeID#" }))
        )
        .Pageable()
        .Sortable()
        .ToClientTemplate()
)
</script>

The .ToClientTemplate() is important. Also need to have different grid names for each row. You can mix in other HTML for organization if desired. See here.

Steve Greene
  • 12,029
  • 1
  • 33
  • 54