GridViewSettings.SetDataItemTemplateContent(Action<GridViewDataItemTemplateContainer>) Method
Allows you to specify a data cell template.
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 common to all the grid data cells.
@Html.DevExpress().GridView(settings =>
{
settings.Name = "GridView";
...
// Setting a template to render all the data cells within a Grid
settings.SetDataItemTemplateContent(cell => {
ViewContext.Writer.Write("<span style=\"color:red\">" + cell.Text + "</span>");
});
settings.Columns.Add("LastName");
settings.Columns.Add("FirstName");
...
}).Bind(Model).GetHtml()
The image below illustrates the result.
Note
Batch Edit Mode Limitations
When adding new rows in Batch Editing mode, only a light (client HTML hierarchy) copy of the server MVC extensions in the template defined via the Grid