This is a migrated thread and some comments may be shown as answers.

Conditional Column

1 Answer 323 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stephen
Top achievements
Rank 1
Stephen asked on 10 Jan 2013, 09:51 PM

Hi, I've been looking at this for sometime and I've even tried a few example that apparently work but they don't for me.  All I want to do is say if ErrorCount > 0 then add a link similar to the WarningCount.  Just to get the basics up and running and following an example I simply want to say if ErrorCount > 0 then show 'Yes' otherwise show 'No'. For some reason it seems to ignore the ClientTemplate and just show the ErrorCount value.  Any ideas?? Please see the code below;

Many thanks.

Steve
@(Html.Kendo().Grid(Model)
    .Name("Grid")
    .HtmlAttributes(new { style = "height: 500px" })
    .Columns(columns =>
    {
        columns.Bound(p => p.ImportTypeName);
        columns.Bound(p => p.ImportedRecordCount);
        columns.Bound(p => p.FeedRecordCount);
        columns.Bound(p => p.ErrorCount).ClientTemplate("# if (ErrorCount > 0) { #" + "Yes" +
                "# } else { #" + "No" + "#}#");
 
        columns.Bound(p => p.WarningCount).Template(
       
 
  @<text>
<a href="@Url.Content("~/client/view/warnings/" + @item.ImportTypeID)">@item.WarningCount</a>
</text>);
 
 
        columns.Bound(p => p.CompletedOn);
 
    })
    .Sortable()
    .Scrollable()
    .Filterable()
 
)

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 14 Jan 2013, 08:05 AM
Hi Stephen,

The client template will not work as the Grid from the code snippet is using server binding. You may know that the ClientTemplate is used only when Grid is populate via AJAX binding. If server binding is used, a server Template is required.

Regards,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Stephen
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or