OptionLabel and Calculated Field

4 posts, 0 answers
  1. Shawn
    Shawn avatar
    7 posts
    Member since:
    Oct 2013

    Posted 10 Jan 2014 Link to this post

    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!
  2. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 14 Jan 2014 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. Shawn
    Shawn avatar
    7 posts
    Member since:
    Oct 2013

    Posted 14 Jan 2014 Link to this post

    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.
  5. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 16 Jan 2014 Link to this post

    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!
Back to Top
Kendo UI is VS 2017 Ready