Grid / Hierarchy and Conditional Statements

4 posts, 0 answers
  1. Randy
    Randy avatar
    12 posts
    Member since:
    Sep 2016

    Posted 27 Oct 2017 Link to this post

    <script id="SCTemplate" type="text/kendo-tmpl">
        @(Html.Kendo().Grid<SCVM>()
              .Name("grid_#=SCartID#") // template expression, to be evaluated in the master context
              .Columns(columns =>
              {
                  columns.Bound(c => c.ci.SCID).Hidden().HtmlAttributes(new { @id = "SCID" });
                  columns.Bound(c => c.ci.FN).Title("Name");
                  columns.Bound(c => c.ci.IN).Hidden(true);
                  columns.Bound(c => c.ci.FN).Title("Item Number").Width(150);
                  columns.Bound(c => c.ci.IsDO).Title("Order Type").ClientTemplate("#if(convertToBoolean(cosci)){#<span class='glyphicon glyphicon-envelope'>hello</span#}#").HtmlAttributes(new { @class = "js-bl" }) ;

     

     

    The above is a code snippet from a Hierarchical Grid Template. What I am attempting to do is show an icon based on the value of "cosci". The issue is, this value is null. The type of this object is string. But when the page is hit, the value is gone. My Previous attempts had me set the object type to boolean. In all cases, it always came back as null. Interestingly enough, the c.ci.IsDO is "true", and it's type is boolean. Is it possible to have conditional statements in a child template? Please provide source files or a link to documentation that will shed light on the issue; but not http://demos.telerik.com/aspnet-mvc/grid/, as that link does not address the issue. 

    FWIW, the convertToBoolean is a function I was using in attempt to change the types to achieve my desired result(s), this fails, because the sequence in which the objects are loaded into the DOM is unexpected.

     

    Thanks.

  2. Angel Petrov
    Admin
    Angel Petrov avatar
    1146 posts

    Posted 31 Oct 2017 Link to this post

    Hi,

    Based on the provided information it would be difficult to provide a precise answer. Can you please elaborate more on how is the cosci value used as I do not see it in the context of the grid? Am I missing something?

    Additionally please check for JavaScript errors that may be caused by the use of the template. If such are present please escape the hashtags as per the suggestion in this forum post.

    Regards,
    Angel Petrov
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Randy
    Randy avatar
    12 posts
    Member since:
    Sep 2016

    Posted 20 Feb 2018 in reply to Angel Petrov Link to this post

    Now that I'm circling back to this issue, some 4 months later. I'm not sure what that values is supposed to be.

     

    The following is a better example:

     

    <script id="SCTemplate" type="text/kendo-tmpl">
        @(Html.Kendo().Grid<SCVM>()
              .Name("grid_#=SCartID#") // template expression, to be evaluated in the master context
              .Columns(columns =>
              {
                  columns.Bound(c => c.ci.SCID).Hidden().HtmlAttributes(new { @id = "SCID" });
                  columns.Bound(c => c.ci.FullName).Title("Name");
                  columns.Bound(c => c.ci.ItemNumber).Title("Item Number").Width(150);
                  columns.Bound(c => c).Title("Order Type").ClientTemplate("#if(convertToBoolean(ci.CanReOrder)){#<span class='glyphicon glyphicon-envelope'></span#}#").HtmlAttributes(new { @class = "js-bl" }) ;

     

    FWIW, I've also tried this: https://docs.telerik.com/kendo-ui/framework/templates/overview#template-syntax however, I'm still unable to get the template to recognize the boolean value. 

     

    Thanks.

     

     

     

     

     

     
  4. Angel Petrov
    Admin
    Angel Petrov avatar
    1146 posts

    Posted 22 Feb 2018 Link to this post

    Hello,

    Are you receiving an error? It would be best to open a formal support ticket in which to attach a sample illustrating the issue so we could debug it and provide a straight to the point suggestion.

    Regards,
    Angel Petrov
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top