Back to Devexpress

ExtensionsFactory.TreeList<RowType>(Action<TreeListSettings<RowType>>) Method

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

latest3.4 KB
Original Source

ExtensionsFactory.TreeList<RowType>(Action<TreeListSettings<RowType>>) Method

Creates a TreeList.

Namespace : DevExpress.Web.Mvc.UI

Assembly : DevExpress.Web.Mvc5.v25.2.dll

NuGet Package : DevExpress.Web.Mvc5

Declaration

csharp
public TreeListExtension<RowType> TreeList<RowType>(
    Action<TreeListSettings<RowType>> method
)
    where RowType : class
vb
Public Function TreeList(Of RowType As Class)(
    method As Action(Of TreeListSettings(Of RowType))
) As TreeListExtension(Of RowType)

Parameters

NameTypeDescription
methodAction<TreeListSettings<RowType>>

A delegate method that accepts TreeListSettings<RowType> as a parameter.

|

Type Parameters

Name
RowType

Returns

TypeDescription
TreeListExtension<RowType>

A TreeListExtension<RowType> object implementing the TreeList functionality.

|

Remarks

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.

cshtml
@(
    // 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

Tree List

Column Binding Via LambdasOnline demo:

ExtensionsFactory Class

ExtensionsFactory Members

DevExpress.Web.Mvc.UI Namespace