Skip to main content
JS

CollectionFactoryExpressionExtensions.AddFor<TRow, TProperty>(CollectionFactory<TreeListColumnBuilder<TRow>>, Expression<Func<TRow, TProperty>>) Method

Adds columns to a strongly-typed TreeList.

Namespace: DevExtreme.AspNet.Mvc

Assembly: DevExtreme.AspNet.Core.dll

Declaration

public static TreeListColumnBuilder<TRow> AddFor<TRow, TProperty>(
    this CollectionFactory<TreeListColumnBuilder<TRow>> factory,
    Expression<Func<TRow, TProperty>> expression
)

Parameters

Name Type Description
factory CollectionFactory<TreeListColumnBuilder<TRow>>

The TreeList column collection factory.

expression Expression<Func<TRow, TProperty>>

A strongly-typed lambda expression. Returns a model property that supplies data to a column.

Type Parameters

Name Description
TRow

The model type of the strongly-typed TreeList.

TProperty

The type of the expression result.

Returns

Type Description
TreeListColumnBuilder<TRow>

A reference to this instance after the method is called.

Remarks

Use this extension method to add columns to a strongly-typed TreeList.

The method performs the following actions:

  • Creates a new column
  • Binds the column to the model property specified by the lambda expression
  • Returns a TreeListColumnBuilder<T> instance so you can use its methods to customize the column
@(Html.DevExtreme().TreeList<OrderViewModel>()
    .Columns(columns => {
        columns.AddFor(m => m.OrderDate); // call methods in a chain to customize the column
        columns.AddFor(m => m.ShipCity);
    })
)

Refer to Nested Options and Collections for more information.

See Also