How to implement hierarchy in the Data Grid with multiple key fields

1 Answer 89 Views
Grid
Patrick
Top achievements
Rank 1
Veteran
Patrick asked on 17 Feb 2023, 03:45 PM | edited on 17 Feb 2023, 03:46 PM

Hello,

I need to implement hierarchical data grid where the relationship between parent-child records is two fields. Can you provide an example of how to establish the relationship in the grid using multiple key fields, please?

Thank you.

Patrick

1 Answer, 1 is accepted

Sort by
0
Anton Mironov
Telerik team
answered on 22 Feb 2023, 08:17 AM

Hello Patrick,

Thank you for the details provided.

When implementing a hierarchy of Telerik UI Grids, they need only a unique Id(Name). So feel free to use the needed relations in the BackEnd and in the DataBase.

// Child Grid:
    @(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()
    )

The following demo represents the described implementation needed for a hierarchy of Grids:

Kind Regards,
Anton Mironov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Grid
Asked by
Patrick
Top achievements
Rank 1
Veteran
Answers by
Anton Mironov
Telerik team
Share this question
or