ExtensionsFactory.CardView<CardType>(CardViewSettings<CardType>) Method
Creates a CardView.
Namespace: DevExpress.Web.Mvc.UI
Assembly: DevExpress.Web.Mvc5.v24.1.dll
NuGet Package: DevExpress.Web.Mvc5
Declaration
public CardViewExtension<CardType> CardView<CardType>(
CardViewSettings<CardType> settings
)
where CardType : class
Parameters
Name | Type | Description |
---|---|---|
settings | CardViewSettings<CardType> | A delegate method that accepts CardViewSettings<CardType> as a parameter. |
Type Parameters
Name |
---|
CardType |
Returns
Type | Description |
---|---|
CardViewExtension<CardType> | A CardViewExtension<CardType> object implementing the CardView functionality. |
Remarks
To enable binding CardView columns to Model fields using lambdas, it is required to declare the CardView extension using the CardView<CardType> strongly-typed declaration method.
Note
The partial View with the CardView extension does not need to be strongly-typed.
The code example below demonstrates how to declare the strongly-typed CardView with columns bound to data model fields via lambda expressions.
@(
// CardView displays instances of the Customer class.
Html.DevExpress().CardView<Customer>(settings => {
settings.Name = "cardView";
settings.CallbackRouteValues = new { Controller = "Home", Action = "CardViewPartial" };
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