# Configuring Local Hierarchical Data with CheckBox Functionality

## Environment

<table>
	<tbody>
		<tr>
			<td>Product Version</td>
			<td>2020.1.114</td>
		</tr>
		<tr>
			<td>Product</td>
			<td>Progress® Kendo UI® TreeView for ASP.NET MVC</td>
		</tr>
	</tbody>
</table>

## Description

Is there a way to set the hierarchical configuration in the model to a Kendo UI TreeView locally with checkbox selection?

## Solution

The Kendo UI TreeView can be bound to a defined model from a controller and can be modified to specify if the item is checked or not.  For example, here is the same TreeView used in the [Binding to Local Data Live Demo](https://demos.telerik.com/aspnet-mvc/treeview/local-data-binding) with [checkbox functionality](https://docs.telerik.com/aspnet-mvc/html-helpers/navigation/treeview/checkboxes).  It is configured with [Local Data Binding](https://docs.telerik.com/aspnet-mvc/html-helpers/navigation/treeview/binding#local-data-binding) using the BindTo() method.

```Razor View
@using NameSpace.Models
@using Kendo.Mvc.UI.Fluent


@(Html.Kendo().TreeView()
        .Name("treeview")
        .Checkboxes(checkboxes => checkboxes
            .Name("checkedFiles")
            .CheckChildren(true)
        )
        //Inline data is set with the BindTo method
        .BindTo((IEnumerable<CategoryItem>)ViewBag.inline, (NavigationBindingFactory<TreeViewItem> mappings) =>
        {
            mappings.For<CategoryItem>(binding => binding.ItemDataBound((item, category) =>
                {
                    item.Text = category.CategoryName;
                    item.Checked = category.Checked;  
                })
                .Children(category => category.SubCategories));
                
            mappings.For<SubCategoryItem>(binding => binding.ItemDataBound((item, subCategory) =>
            {
                item.Text = subCategory.SubCategoryName;
                item.Checked = subCategory.Checked;
            }));
        })
)
```

```C# Controller
        public ActionResult Index()
        {
            //Data is passed by the ViewBag
            ViewBag.inline = Local_Data_Binding_Get_Inline_Data();

            return View();
        }


        private IEnumerable<CategoryItem> Local_Data_Binding_Get_Inline_Data()
        {
            //Inline data which defines the model
            List<CategoryItem> inline = new List<CategoryItem>
                {
                    new CategoryItem
                    {
                        CategoryName = "Storage",
                        Checked = false,
                        SubCategories = new List<SubCategoryItem>
                        {
                            new SubCategoryItem()
                            {
                                SubCategoryName = "Wall Shelving",
                                Checked = true,
                            },
                            new SubCategoryItem
                            {
                                 SubCategoryName = "Floor Shelving",
                                 Checked = true,
                            },
                            new SubCategoryItem
                            {
                                 SubCategoryName = "Kids Storage",
                                 Checked = false,
                            }
                        }
                    },
                    new CategoryItem
                    {
                        CategoryName = "Lights",
                        Checked = false,
                        SubCategories = new List<SubCategoryItem>
                        {
                            new SubCategoryItem()
                            {
                                SubCategoryName = "Ceiling",
                                Checked = true,
                            },
                            new SubCategoryItem
                            {
                                 SubCategoryName = "Table",
                                 Checked = false,
                            },
                            new SubCategoryItem
                            {
                                 SubCategoryName = "Floor",
                                 Checked = true,
                            }
                        }
                    }
                };

            return inline;
        }
```

## More ASP.NET MVC TreeView Resources

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

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

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

* [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 TreeView for ASP.NET MVC](https://docs.telerik.com/kendo-ui/api/ui/treeview)
* [Server-Side API Reference of the TreeView for ASP.NET MVC](https://docs.telerik.com/aspnet-mvc/api/treeview)
* [Telerik UI for ASP.NET MVC Breaking Changes](https://www.telerik.com/aspnet-mvc/documentation/backwards-compatibility/2023-backwards-compatibility)
* [Telerik UI for ASP.NET MVC Knowledge Base](https://docs.telerik.com/aspnet-mvc/knowledge-base)
