Accessing child data in hierarchy grid using server binding

1 Answer 57 Views
Grid
Juan Alberto
Top achievements
Rank 1
Juan Alberto asked on 21 Jun 2023, 10:57 AM

Hello, I am dealing with an issue while implementing a hierarchy grid using server binding. I need to access data child in server so I can modify this data as I need. 

I.E. 

columns.Bound(pet => pet.Origen).Width(100).HtmlAttributes( new {@title = item.title});

I would need to display the tooltip I have in my model, but the problem is that "item" reffers to the father row, not the child. How can I get this done?

 

I don't know if I am using the correct approach here, any help would be appreciated.

Thanks and best regards.

1 Answer, 1 is accepted

Sort by
1
Accepted
Patrick | Technical Support Engineer, Senior
Telerik team
answered on 26 Jun 2023, 07:01 PM

Hello Juan Alberto,

In this particular use-case, I would recommend utilizing Ajax databinding similar to the example shown in this Kendo UI Grid live demo. Then, setting the title can be configured with a ClientTemplate:

JavaScript

    @(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).ClientTemplate("<div title='\\#=OrderID\\#'>\\#= OrderID \\#</div>");
                columns.Bound(o => o.ShipCountry).Width(150).ClientTemplate("<div title='\\#=ShipCountry\\#'>\\#= ShipCountry \\#</div>");
                columns.Bound(o => o.ShipAddress).ClientTemplate("<div title='\\#=ShipAddress\\#'>\\#= ShipAddress \\#</div>"); 
                columns.Bound(o => o.ShipName).Width(300).ClientTemplate("<div title='\\#=ShipName\\#'>\\#= ShipName \\#</div>");
            })
            .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(10)
                .Read(read => read.Action("HierarchyBinding_Orders", "Grid", new { employeeID = "#=EmployeeID#" }))
            )
            .Pageable()
            .Sortable()
            .ToClientTemplate()
    )

Regards,
Patrick | Technical Support Engineer, Senior
Progress Telerik

As of R2 2023, the default icon type will be SVG instead of Font. See this blogpost for more information.

Tags
Grid
Asked by
Juan Alberto
Top achievements
Rank 1
Answers by
Patrick | Technical Support Engineer, Senior
Telerik team
Share this question
or