aspnetmvc-devexpress-dot-web-dot-mvc-dot-ui-dot-extensionsfactory-dot-treelist-1-x28-system-dot-action-devexpress-dot-web-dot-mvc-dot-treelistsettings-0-x29.md
Creates a TreeList.
Namespace : DevExpress.Web.Mvc.UI
Assembly : DevExpress.Web.Mvc5.v25.2.dll
NuGet Package : DevExpress.Web.Mvc5
public TreeListExtension<RowType> TreeList<RowType>(
Action<TreeListSettings<RowType>> method
)
where RowType : class
Public Function TreeList(Of RowType As Class)(
method As Action(Of TreeListSettings(Of RowType))
) As TreeListExtension(Of RowType)
| Name | Type | Description |
|---|---|---|
| method | Action<TreeListSettings<RowType>> |
A delegate method that accepts TreeListSettings<RowType> as a parameter.
|
| Name |
|---|
| RowType |
| Type | Description |
|---|---|
| TreeListExtension<RowType> |
A TreeListExtension<RowType> object implementing the TreeList functionality.
|
To enable binding TreeList columns to Model fields using lambdas, it is required to declare the TreeList extension using the TreeList<RowType> strongly-typed declaration method.
Note
The partial View with the TreeList extension does not need to be strongly-typed.
The code example below demonstrates how to declare the strongly-typed TreeList with columns bound to data model fields via lambda expressions.
@(
// TreeList displays instances of the EditablePost class.
Html.DevExpress().TreeList<EditablePost>(settings => {
settings.Name = "treeList";
settings.CallbackRouteValues = new { Controller = "Home", Action = "TreeListPartial" };
settings.KeyField(m => m.PostID);
settings.ParentField(m => m.ParentID);
// The following columns are bound to Model fields via lambdas.
settings.Columns.Add(m => m.From);
settings.Columns.Add(m => m.Subject);
settings.Columns.Add(m => m.PostDate);
settings.Columns.Add(m => m.IsNew, c => c.ColumnType = MVCxTreeListColumnType.CheckBox);
settings.Columns.Add(m => m.HasAttachment, c => c.ColumnType = MVCxTreeListColumnType.CheckBox);
}).Bind(Model).GetHtml()
)
See Also