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

Grid / Hierarchy and Conditional Statements

3 Answers 144 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Randy
Top achievements
Rank 1
Randy asked on 27 Oct 2017, 05:19 PM

<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.

3 Answers, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 31 Oct 2017, 02:55 PM
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.
0
Randy
Top achievements
Rank 1
answered on 20 Feb 2018, 03:33 PM

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.

 

 

 

 

 

 
0
Angel Petrov
Telerik team
answered on 22 Feb 2018, 02:19 PM
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.
Tags
Grid
Asked by
Randy
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Randy
Top achievements
Rank 1
Share this question
or