New to Telerik UI for ASP.NET MVCStart a free 30-day trial

Use Hierarchy Binding with PanelBar

Environment

ProductTelerik UI for ASP.NET MVC PanelBar
Product VersionCreated with version 2024.4.1112

Description

How can I display hierarchical data in the PanelBar component?

Solution

  1. Create a List collection of type PanelBarItemModel and access it in the view.
  2. Use the BindTo() method of the PanelBar to bind the component to the collection.
Razor
@using Kendo.Mvc.UI.Fluent;
@model List<Kendo.Mvc.UI.PanelBarItemModel>
@(Html.Kendo().PanelBar()
      .Name("panelbar")
            .BindTo((List<PanelBarItemModel>)Model, (NavigationBindingFactory<PanelBarItem> mappings) =>
            {
                mappings.For<PanelBarItemModel>(binding => binding.ItemDataBound((item, category) =>
                    {
                        item.Text = category.Text;
                    })
                    .Children(category => category.Items));
            })
)

To see the complete example, refer to the ASP.NET MVC application in the UI for ASP.NET MVC Examples repository that demonstrates a PanelBar component bound to hierarchical data.

More ASP.NET MVC PanelBar Resources

See Also