ExtensionsFactory.GridView<RowType>(Action<GridViewSettings<RowType>>) Method
Creates a GridView.
Namespace: DevExpress.Web.Mvc.UI
Assembly: DevExpress.Web.Mvc5.v24.2.dll
Declaration
public GridViewExtension<RowType> GridView<RowType>(
Action<GridViewSettings<RowType>> method
)
where RowType : class
Parameters
Name | Type | Description |
---|---|---|
method | Action<GridViewSettings<RowType>> | A delegate method that accepts GridViewSettings<RowType> as a parameter. |
Type Parameters
Name |
---|
RowType |
Returns
Type | Description |
---|---|
GridViewExtension<RowType> | A GridViewExtension<RowType> object implementing the GridView functionality. |
Remarks
To enable binding grid columns to Model fields using lambdas, it is required to declare the GridView extension using the GridView<RowType> strongly-typed declaration method.
Note
The partial View with the GridView extension does not need to be strongly-typed.
The code example below demonstrates how to declare the strongly-typed GridView with columns bound to data model fields via lambda expressions.
@(
// Grid displays instances of the Customer class.
Html.DevExpress().GridView<Customer>(settings => {
settings.Name = "grid";
settings.CallbackRouteValues = new { Controller = "Home", Action = "GridViewPartial" };
settings.KeyFields(m => m.CustomerID);
// The following columns are bound to Model fields via lambdas.
settings.Columns.Add(m => m.ContactName, column => {
column.SortIndex = 0;
column.SortOrder = DevExpress.Data.ColumnSortOrder.Ascending;
});
settings.Columns.Add(m => m.CompanyName);
settings.Columns.Add(m => m.Country);
settings.Columns.Add(m => m.City);
settings.Columns.Add(m => m.Region);
}).Bind(Model).GetHtml()
)
See Also