New to Telerik UI for ASP.NET MVC? Start a free 30-day trial
Updating and Adding Text to the Expand and Collapse Icons in the Hierarchy Grid
Environment
Product | Telerik UI for ASP.NET MVC Grid |
Progress Telerik UI for ASP.NET MVC version | Created with the 2022.3.1109 version |
Description
How can I change the Expand and Collapse icons in the Telerik UI for ASP.NET MVC Hierarchy Grid and add text to the icons?
Solution
To achieve the desired scenario:
- Update the Expand and Collapse icons by using the common classes provided by Kendo. For the full list of the available Kendo UI Web Font Icons, refer to the list of Font icons.
- To add initial text icons once the data is bound to the Grid, subscribe to the
DataBound
event. - To add text to the Expand and Collapse icons, subscribe to both the
DetailExpand
andDetailCollapse
events and alter the initially provided style classes by using the conventional removeclass() and text() jQuery methods.
Index.cshtml
@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.EmployeeViewModel>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(e => e.FirstName).Width(100);
columns.Bound(e => e.LastName).Width(110);
columns.Bound(e => e.Country).Width(110);
columns.Bound(e => e.City).Width(110);
columns.Bound(e => e.Title);
})
.Sortable()
.Pageable()
.Scrollable()
.ClientDetailTemplateId("template")
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(6)
.Read(read => read.Action("HierarchyBinding_Employees", "Grid"))
)
.Events(events => {
events.DataBound("onDataBound");
events.DetailExpand("onDetailExpand");
events.DetailCollapse("onDetailCollapse");
})
)
For the complete implementation of the suggested approach, refer to the Telerik REPL example on updating and adding both the Expand and Collapse icons for the Hierarchy Grid for ASP.NET MVC.