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

OptionLabel and Calculated Field

3 Answers 53 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Shawn
Top achievements
Rank 2
Shawn asked on 10 Jan 2014, 05:55 PM
I have a MVVM DropDownList that uses a ViewModel whose DataSource uses a Model with a calculated field. If I attempt to set data-option-label on the DropDownList, I get "TypeError: d.<MyCalculatedField> is not a function". What can I do? This implementation works great on a DropDownList without a calculated field in its Model. Thanks!

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 14 Jan 2014, 11:44 AM
Hello Shawn,

I tried to reproduce the problem on my side but to no avail. Could you check this jsBin and let me know if I am missing something?

Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Shawn
Top achievements
Rank 2
answered on 14 Jan 2014, 03:37 PM
Try to use the calculated field as the dropdown text, and the dropdown won't load. That was not my specific problem - in my implementation, I could get the list to load with the text as a calculated field, but not show the option label. I cannot get it to do that, here - not sure why.
0
Daniel
Telerik team
answered on 16 Jan 2014, 09:52 AM
Hello again Shawn,

The items will not be loaded because of a JavaScript error thrown because the dropdownlist will initially be assigned with a default dataSource that does not have the calculated field. It is possible to avoid the error by using the data-source attribute to set the dataSource instead of source binding. Another option is to use the autoBind option to prevent the widget from binding to the data from the initial dataSource. In both cases, in order to use an option label in this scenario, you will also need to set an object with the calculated field set as function. I updated the jsBin to demonstrate both options. 

Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
DropDownList
Asked by
Shawn
Top achievements
Rank 2
Answers by
Daniel
Telerik team
Shawn
Top achievements
Rank 2
Share this question
or