# Use Hierarchy Binding with PanelBar

## Environment

<table>
 <tr>
  <td>Product</td>
  <td>Telerik UI for ASP.NET MVC PanelBar</td>
 </tr>
 <tr>
  <td>Product Version</td>
  <td>Created with version 2024.4.1112</td>
 </tr>
</table>

## Description

How can I display hierarchical data in the PanelBar component?

## Solution

1. Create a `List` collection of type [`PanelBarItemModel`](https://www.telerik.com/aspnet-mvc/documentation/api/kendo.mvc.ui/panelbaritemmodel) and access it in the view.
2. Use the [`BindTo()`](https://www.telerik.com/aspnet-mvc/documentation/api/kendo.mvc.ui.fluent/panelbarbuilder#bindtosystemcollectionsienumerablesystemaction) method of the PanelBar to bind the component to the collection.

```Razor HtmlHelper
@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));
            })
)
```

```C# Controller
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            IEnumerable<PanelBarItemModel> Items = new List<PanelBarItemModel>
                {
                    new PanelBarItemModel
                    {
                        Text = "Furniture",
                        Items = new List<PanelBarItemModel>
                        {
                            new PanelBarItemModel()
                            {
                                Text = "Tables & Chairs"
                            },
                            new PanelBarItemModel
                            {
                                 Text = "Sofas"
                            },
                            new PanelBarItemModel
                            {
                                 Text = "Occasional Furniture"
                            }
                        }
                    },
                    new PanelBarItemModel
                    {
                        Text = "Decor",
                        Items = new List<PanelBarItemModel>
                        {
                            new PanelBarItemModel()
                            {
                                Text = "Bed Linen"
                            },
                            new PanelBarItemModel
                            {
                                 Text = "Curtains & Blinds"
                            },
                            new PanelBarItemModel
                            {
                                 Text = "Carpets"
                            }
                        }
                    }
                };
            return View(Items);
        }
    }
```

To see the complete example, refer to the [ASP.NET MVC application](https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/Telerik.Examples.Mvc/Telerik.Examples.Mvc/Areas/PanelBarHierarchyBinding) in the [UI for ASP.NET MVC Examples repository](https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master) that demonstrates a PanelBar component bound to hierarchical data.

## More ASP.NET MVC PanelBar Resources

* [ASP.NET MVC PanelBar Documentation](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/panelbar/overview)

* [ASP.NET MVC PanelBar Demos](https://demos.telerik.com/aspnet-mvc/panelbar)

* [ASP.NET MVC PanelBar Product Page](https://www.telerik.com/aspnet-mvc/panelbar)

* [Telerik UI for ASP.NET MVC Video Onboarding Course (Free for trial users and license holders)](https://www.telerik.com/aspnet-mvc/documentation/getting-started/video-onboarding)

* [Telerik UI for ASP.NET MVC Forums](https://www.telerik.com/forums/aspnet-mvc)

## See Also

* [Client-Side API Reference of the PanelBar for ASP.NET MVC](https://docs.telerik.com/kendo-ui/api/ui/panelbar)
* [Server-Side API Reference of the PanelBar for ASP.NET MVC](https://docs.telerik.com/aspnet-mvc/api/panelbar)
* [Telerik UI for ASP.NET MVC Breaking Changes](https://www.telerik.com/aspnet-mvc/documentation/backwards-compatibility/2024-backwards-compatibility)
* [Telerik UI for ASP.NET MVC Knowledge Base](https://docs.telerik.com/aspnet-mvc/knowledge-base)
