New to Telerik UI for ASP.NET MVC? Download free 30-day trial
ASP.NET MVC DropDownTree Local Data Binding
- EXAMPLE
- VIEW SOURCE
-
Change Theme
defaultDefault Theme
- Main
- Main Dark
- Nordic
- Ocean Blue
- Ocean Blue A11Y
- Purple
- Turquoise
Bootstrap Theme- Main
- Bootstrap 3
- Bootstrap 3 Dark
- Main Dark
- Nordic
- Turquoise
- Turquoise Dark
- Urban
- Vintage
Material Theme- Main
- Arctic
- Lime Dark
- Main Dark
- Material 2
- Material 2 Dark
- Nova
Classic Theme- Main
- Green
- Green Dark
- Lavender
- Lavender Dark
- Main Dark
- Metro
- Metro Dark
- Moonlight
- Opal
- Opal Dark
- Silver
- Silver Dark
- Uniform
Fluent Theme- Main
- Main Dark
Also available for:
CLIENT-SIDE API SERVER-SIDE APIDescription
The Telerik UI for ASP.NET MVC DropDownTree supports local data binding and you can display local data in the component.
To implement local data binding, you need to return a collection (list) of objects from the Controller to the View, for example, by saving that collection in a Model field, and then load the data in the DropDownTree.
The current example demonstrates two approaches for binding the DropDownTree to local data:
- (Default) Using inline data—An
IEnumerableofDropDownTreeItemModelis stored in aViewBagand passed to theBindTo()method. TheDropDownTreeItemModelhas anItemsfield that holds the child nodes (it is aListproperty). If a given node has items, the Expand icon will be visible. - Mapping
Modelproperties—AnIEnumerableof a specifiedModel, for example, CategoryItem, is stored in aViewBagand passed to another overload of theBindTo()method: the first argument is anIEnumerableof aModel, and the second is the action, which creates a hierarchy of items by using the specified mappings. For example, the child nodes will be bound to the SubCategories property, and theCategoryItemModelproperties will be mapped toDropDownTreeItemproperties.