Conditional Column

2 posts, 0 answers
  1. Stephen
    Stephen avatar
    1 posts
    Member since:
    Nov 2012

    Posted 10 Jan 2013 Link to this post


    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()
     
    )
  2. Rosen
    Admin
    Rosen avatar
    3253 posts

    Posted 14 Jan 2013 Link to this post

    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!
Back to Top