Reputation: 487
I am working on asp.net MVC. And I want to display the list in grid view. I am using telerik grid view. I have to display one boolean type field in gridview. Suppose the value of it is False then it must display as "Closed" else "Active" in telerik grid. My sample code is :
<td>
@(Html.Telerik().Grid<test>()
.Name("test-grid")
.BindTo(Model.Data)
.Columns(columns =>
{
columns.Bound(x => x.Id)
.Centered();
columns.Bound(x => x.Name)
.Centered();
columns.Bound(x => x.Class)
.Centered();
columns.Bound(x => x.Remarks)
.Centered();
columns.Bound(x => x.IsActive)
.Centered();
columns.Bound(x => x.Progress)
.Template(x => x.Progress + "%")
.Centered()
.Filterable(true);
})
</td>
My grid view shows me IsActive status in checkbox(readonly). I wants some different from that. I have to display in words as "Active" or "Closed". How can i do this?
Upvotes: 1
Views: 1199
Reputation: 3818
Try
<td>
@(Html.Telerik().Grid<test>()
.Name("test-grid")
.BindTo(Model.Data)
.Columns(columns =>
{
columns.Bound(x => x.Id)
.Centered();
columns.Bound(x => x.Name)
.Centered();
columns.Bound(x => x.Class)
.Centered();
columns.Bound(x => x.Remarks)
.Centered();
columns.Bound(x => x.IsActive)
.ClientTemplate("<# if(IsActive) { #>Active<# } else {#>Closed<# } #>")
.Centered();
columns.Bound(x => x.Progress)
.Template(x => x.Progress + "%")
.Centered()
.Filterable(true);
})
</td>
Upvotes: 1