Kendo GridView cell value alias
-
21-12-2019 - |
Question
I want to change the value of the IsActive column from True and False to Yes and No. The code is as follows:
@(Html.Kendo().Grid<Silverback.Vitae.Core.Models.FormModel>()
.Name("Grid")
.Columns(columns =>
{
columns.Bound(p => p.Name);
columns.Bound(p => p.IsActive).Width(100).HeaderHtmlAttributes(new { @style = "text-align:center;" }).HtmlAttributes(new { @style = "text-align:center;" });
columns.Bound(p => p.FormID).ClientTemplate("#= actionTemplate(data) #").Width(300).HeaderHtmlAttributes(new { @style = "text-align:center;" }).HtmlAttributes(new { @style = "text-align:center;" }).Title("Action").Sortable(false);
})
.Pageable()
.Sortable()
.Scrollable(s => s.Height("auto"))
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("GetForms", "Forms"))
)
)
Solution
ClientTemplate is the thing that will bring you to success. The same is explained in the FAQ here.
ClientTemplate(" #= IsActive ? 'Foo' : 'Bar' #")
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow