Change Theme Settings
Change Theme Settings
Themes
 
Metropolis
Moderno
iOS
Material
Material Compact
Office 365
Mulberry
Show All Themes
v
...v

Column Binding via Lambdas

Country Ascending
Contact Name Ascending
Company Name 
City 
Region 
CollapseCountry: Argentina
 Patricio SimpsonCactus Comidas para llevarBuenos Aires 
 Sergio GutiérrezRancho grandeBuenos Aires 
 Yvonne MoncadaOcéano Atlántico Ltda.Buenos Aires 
CollapseCountry: Austria
 Georg PippsPiccolo und mehrSalzburg 
 Roland MendelErnst HandelGraz 
CollapseCountry: Belgium
 Catherine DeweyMaison DeweyBruxelles 
 Pascale CartrainSuprêmes délicesCharleroi 
Page 1 of 12 (112 items)Prev1234567101112Next


This demo illustrates how to bind grid columns to Model fields using lambda expressions.

To enable binding grid columns to Model fields using lambdas, it is required to declare the GridView extension using the ExtensionsFactory.GridView<RowType> strongly-typed declaration method. This method accepts the GridViewSettings<RowType> object that implements the following specific strongly-typed members.

  • KeyFields. This method defines a key field (or multiple fields for a composite key). In this demo, the key field name is defined using the lambda expression passed as a parameter to the KeyFields method.

  • PreviewField. This method defines a field from which the preview row will retrieve its data.

  • Columns. This property provides access to a collection of strongly-types columns. This collection exposes the specific Add method that accept the lambda expression that defines a particular model field to which the newly created column will be bound.

    The specific Add method overload can also accept the delegate method that returns the column settings object. This overload allows you to add a column with specific settings (see the "Contact Name" column in this demo).

Note that the partial View with the GridView extension does not need to be strongly-typed.