Skip to main content

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

Creates a TreeList.

Namespace: DevExpress.Web.Mvc.UI

Assembly: DevExpress.Web.Mvc5.v24.1.dll

NuGet Package: DevExpress.Web.Mvc5

Declaration

public TreeListExtension<RowType> TreeList<RowType>(
    Action<TreeListSettings<RowType>> method
)
    where RowType : class

Parameters

Name Type Description
method Action<TreeListSettings<RowType>>

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

Type Parameters

Name
RowType

Returns

Type Description
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.

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