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

Can this template be improved? (Conditional)

1 Answer 96 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kjell
Top achievements
Rank 1
Kjell asked on 11 Jan 2017, 03:45 PM

The template below works but it seems kind of goofy.  Is there a better way to set the "Checked" value conditionally?

I can do it easily with a plain checkbox but I prefer to use the Kendo one for the styling.

 

<script type="text/x-kendo-tmpl" id="connectorTemplate">
     <div class="tabOption">
         # if (Selected) { # 
 
         @(Html.Kendo().CheckBox()
                 .Name("#:Id#")
                 .Checked(true)
         )
 
         # } else { #
 
         @(Html.Kendo().CheckBox()
                 .Name("#:Id#")
                 .Checked(false)
         )
 
         # } #
 
         <span>#:Name# </span>
     </div>
 </script>

1 Answer, 1 is accepted

Sort by
0
Stamo Gochev
Telerik team
answered on 13 Jan 2017, 07:19 AM
Hi Kjell,

I think that you can place the Selected condition in the Checked property of the checkbox (similar to what you have done with the Id) and use the ternary operator. The following thread can be used as a reference:

http://stackoverflow.com/a/11040193

Regards,
Stamo Gochev
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
General Discussions
Asked by
Kjell
Top achievements
Rank 1
Answers by
Stamo Gochev
Telerik team
Share this question
or