Skip to main content

MVCxCardViewColumn.SetDataItemTemplateContent(Action<CardViewDataItemTemplateContainer>) Method

Allows you to specify a data cell template.

Namespace: DevExpress.Web.Mvc

Assembly: DevExpress.Web.Mvc5.v24.1.dll

NuGet Package: DevExpress.Web.Mvc5

Declaration

public void SetDataItemTemplateContent(
    Action<CardViewDataItemTemplateContainer> contentMethod
)

Parameters

Name Type Description
contentMethod Action<CardViewDataItemTemplateContainer>

A method to which a template content rendering is delegated.

Remarks

Note

Once a template defined using the SetDataItemTemplateContent method is created, it is instantiated within a container object of the CardViewDataItemTemplateContainer type. This container object exposes a set of members which can be useful when designing a template.

The code sample below demonstrates how to define the template for cells within an individual column.

@Html.DevExpress().CardView(settings =>
{
    settings.Name = "CardView";
    ...
    // Setting a template to render all the data cells within a "ShipName" column
    settings.Columns.Add(column => {
        column.FieldName = "ShipName";
        column.SetDataItemTemplateContent(cell => {
            ViewContext.Writer.Write("<b style=\"font-style:italic\">" + cell.Text + "</b>");
        });
    });
    settings.Columns.Add("ShipCity");
    settings.Columns.Add("ShipPostalCode");
    settings.Columns.Add("ShipCountry");
...
}).Bind(Model).GetHtml()

The image below illustrates the result.

CardView_Templates_BoldItalicText

See Also