About the Tree List
The DevExpress ASP.NET MVC TreeList extension combines the power of the Grid with the hierarchical structure of the TreeView. Like the GridView, the TreeList supports binding to data, editing data, sorting, and more.
Follow the three simple steps below to add a DevExpress TreeList extension and bind it to your data. It's easy as “M”, “V”, and “C”.
1. Model (the "M" in MVC). First, we need a Model object for the DevExpress TreeList to bind to. Create a new data model using the Entity Framework wizard or LinqToSQL ORM from Visual Studio. However, you can use any model that supports the IEnumerable or IQueryable interface. Since the TreeList is designed to display information in a tree structure, its data source needs two additional fields to build a tree structure. The first is a "Key Field" that must contain unique values. And the second is a "Parent Field" that must contain values that indicate parent nodes for the current node (learn more in our online documentation).
2. View (the "V" in MVC). Next declare the TreeList extension inside of the View. Specifically, you will create a Partial View because the DevExpress TreeList extension provides AJAX callbacks by default, to give your end-users a better experience without updating the entire page. However, because ASP.NET MVC does not support callbacks, declare the TreeList extension inside of a Partial View and define how the callbacks will be routed back to your controller using the CallbackRouteValues property:
Partial View code:
3. Controller (the "C" in MVC). Finally, the controller is where you will need to define the action methods that will handle TreeList's callbacks. The "OverviewPartial" action method below handles the callbacks. The DepartmentsModel.GetData method gets the data from the data source to pass to the View. As you can see, the native DevExpress TreeList extension follows the ASP.NET MVC pattern while providing powerful features for your end-users.
Watch a short nine-minute getting started video now to learn about the DevExpress TreeList extension for ASP.NET MVC.