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

Have function or expression determine checkbox: data-bind="checked: " value

1 Answer 435 Views
Templates
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 04 Aug 2016, 04:03 PM

Here is the situation.

I'm working in a custom editor template for the kendo scheduler.

I have a model with a string field called "itemType".

 The form fields associated with item type are checkboxes.

 

Issue: I want to evaluate whether or not the checkbox should be checked when the editor window is opened.  In order to do this, the most logical thing (in my mind) would be to have some kind of expression to evaluate this.  I tried the following template and I get "Uncaught ReferenceError: Invalid left-hand side in assignment".

 

Here is the template:

1.#for (var i=0; i<itemTypeList.length; i++){#
2.<input name="itemType" type="checkbox" value="#= itemTypeList[i].Code #" data-type="text" data-bind="checked: itemType=='#= itemTypeList[i].Code #'"> #= itemTypeList[i].Description #
3.# } #

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 08 Aug 2016, 03:46 PM
Hello David,

I can assume that the error is caused by this assignment "data-bind="checked: itemType=='#= itemTypeList[i].Code #'". This will not be evaluated to true or false, and will create an incorrect assignment which is causing the error.
 
In order to show the checkboxes as checked depending on a specific value, please use the if statement:

http://docs.telerik.com/kendo-ui/framework/templates/overview#templates-overview

Please check a Dojo example demonstrating this implementation:

http://dojo.telerik.com/EhUbi

I hope this is helpful.
Regards,
Stefan
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
Tags
Templates
Asked by
David
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or