Skip to main content
JS

CollectionFactoryExpressionExtensions.AddSimpleFor<TFormData, TProperty>(FormItemsFactory<TFormData>, Expression<Func<TFormData, TProperty>>) Method

Adds simple items to a strongly-typed Form.

Namespace: DevExtreme.AspNet.Mvc

Assembly: DevExtreme.AspNet.Core.dll

Declaration

public static FormSimpleItemBuilder AddSimpleFor<TFormData, TProperty>(
    this FormItemsFactory<TFormData> factory,
    Expression<Func<TFormData, TProperty>> expression
)

Parameters

Name Type Description
factory FormItemsFactory<TFormData>

The Form item collection factory.

expression Expression<Func<TFormData, TProperty>>

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

Type Parameters

Name Description
TFormData

The model type of the strongly-typed Form.

TProperty

The type of the expression result.

Returns

Type Description
FormSimpleItemBuilder

A reference to this instance after the method is called.

Remarks

Use this extension method to add items to a strongly-typed Form.

The method performs the following actions:

  • Creates a new item
  • Binds the item to the model property specified by the lambda expression
  • Returns a FormSimpleItemBuilder instance so you can use its methods to customize the item
@(Html.DevExtreme().Form<OrderViewModel>()
    .Items(items => {
        items.AddSimpleFor(m => m.OrderDate); // call methods in a chain to customize the column
        items.AddSimpleFor(m => m.ShipCity);
    })
)

Refer to Nested Options and Collections for more information.

See Also