Back to Devexpress

CardViewSettings.CustomUnboundColumnData Property

aspnetmvc-devexpress-dot-web-dot-mvc-dot-cardviewsettings-45c68c98.md

latest3.2 KB
Original Source

CardViewSettings.CustomUnboundColumnData Property

Enables data to be supplied to unbound columns.

Namespace : DevExpress.Web.Mvc

Assembly : DevExpress.Web.Mvc5.v25.2.dll

NuGet Package : DevExpress.Web.Mvc5

Declaration

csharp
public ASPxCardViewColumnDataEventHandler CustomUnboundColumnData { get; set; }
vb
Public Property CustomUnboundColumnData As ASPxCardViewColumnDataEventHandler

Property Value

TypeDescription
ASPxCardViewColumnDataEventHandler

A ASPxCardViewColumnDataEventHandler delegate method allowing you to implement custom processing.

|

Remarks

To provide unbound columns with data using a delegate method, assign this delegate method to the CustomUnboundColumnData property. The delegate method assigned to this property will be called for unbound columns only.

The code sample below demonstrates how to add an unbound column that retrieves data using a delegate method.

Partial View code:

csharp
@Html.DevExpress().CardView(settings => {
    settings.Name = "CardView";
    settings.CallbackRouteValues = new { Controller = "Home", Action = "CardViewPartial" };
    // ...
    // Add columns bound to model fields.
    settings.Columns.Add("FirstName");
    settings.Columns.Add("LastName");
    settings.Columns.Add(column => {
        // "FieldName" contains a unique value that does not refer to any field in the CardView's data model. 
        column.FieldName = "FullName";
        // The column contains string values.
        column.UnboundType = DevExpress.Data.UnboundColumnType.String;
    });
    // A delegate method that allows you to generate data for an unbound column.
    settings.CustomUnboundColumnData = (s, e) => {
        if (e.Column.FieldName == "FullName") {
            string firstName = (e.GetListSourceFieldValue("FirstName")).ToString();
            string lastName = (e.GetListSourceFieldValue("LastName")).ToString();
            e.Value = firstName + " " + lastName;
        };
    };
}).Bind(Model).GetHtml()

Note

When the CardView extension is bound to a data source in Database Server Mode, you can only enable sorting, filtering and summary calculation for unbound columns that are populated with unbound expressions.

See Also

Declaring Server-Side Event Handlers

Card View

CardViewSettings Class

CardViewSettings Members

DevExpress.Web.Mvc Namespace