MVCxGridViewColumn.SetDataItemTemplateContent(Action<GridViewDataItemTemplateContainer>) Method
In This Article
Allows you to specify a template for data cells in the current column.
Namespace: DevExpress.Web.Mvc
Assembly: DevExpress.Web.Mvc5.v24.2.dll
NuGet Package: DevExpress.Web.Mvc5
#Declaration
public void SetDataItemTemplateContent(
Action<GridViewDataItemTemplateContainer> contentMethod
)
#Parameters
Name | Type | Description |
---|---|---|
content |
Action<Grid |
A method to which a template content rendering is delegated. |
#Remarks
Note
Once a template defined using the Set
The code sample below demonstrates how to define the template for cells within an individual column.
@Html.DevExpress().GridView(settings =>
{
settings.Name = "GridView";
...
// Setting a template to render all the data cells within a "LastName" column
settings.Columns.Add(column => {
column.FieldName = "LastName";
column.SetDataItemTemplateContent(cell => {
ViewContext.Writer.Write("<b style=\"font-style:italic\">" + cell.Text + "</b>");
});
});
settings.Columns.Add("FirstName");
...
}).Bind(Model).GetHtml()
The image below illustrates the result.
#Online Demos
#Online Examples
See Also