BootstrapGridViewBuilderBase<T>.Templates(Action<BootstrapGridViewTemplatesBuilder>) Method
Provides access to the templates used to display the Grid View‘s elements (cells, rows, etc.).
Namespace: DevExpress.AspNetCore.Bootstrap
Assembly: DevExpress.AspNetCore.Bootstrap.v18.2.dll
Declaration
Parameters
Name | Type | Description |
---|---|---|
config | Action<BootstrapGridViewTemplatesBuilder> | An Action that configures the BootstrapGridViewTemplatesBuilder class. |
Returns
Type | Description |
---|---|
T | A reference to this instance after the operation is completed. |
Remarks
IMPORTANT
Bootstrap Controls for ASP.NET Core are in maintenance mode. We don’t add new controls or develop new functionality for this product line. Our recommendation is to use the ASP.NET Core Controls suite.
$1 A template is a set of HTML elements that define the layout for a particular element (area) of a control. Grid View provides multiple templates that can be accessed via the Templates property. You can provide templates used for displaying cells, column headers, data rows, preview sections, etc.
NOTE
Online Demo: For more information on templates, refer to the Templates online demo.
The example below illustrates how to create a template to display images along with textual content within preview rows.
@model IEnumerable
@(Html.DevExpress()
.BootstrapGridView<Employee>("grid")
.Settings(settings => settings.ShowPreview(true))
.PreviewFieldName(m => m.Notes)
.Templates(templates => templates
.PreviewRow(t => @<text>
<div class="media">
@(Html.DevExpress()
.BootstrapBinaryImage()
.Name("preview" + t.VisibleIndex)
.CssClasses(css => css.Control("rounded-circle"))
.Value(t.Eval(m => m.Photo)))
<div class="media-body">@t.Text</div>
</div>
</text>))
.KeyFieldName(m => m.EmployeeID)
.Columns(columns => {
columns.Add(m => m.Photo);
columns.Add(m => m.Text);
...
})
.Bind(Model))