kendoDropDownList.select not working in 'Add New item' replica

3 posts, 1 answers
  1. Grant
    Grant avatar
    41 posts
    Member since:
    Jul 2016

    Posted 16 Sep Link to this post

    Hi, 

    Im trying to create a PoC replica of some new functionality added to KendoDropDownList, adding a new Item from the noDataTemplate.

    Im trying to replicate http://demos.telerik.com/kendo-ui/dropdownlist/addnewitem with a static DataSource, however once the new item is added to the dataSource its not being selected, http://dojo.telerik.com/emOWE.

    Regards,
    Grant

    PS - This feels like a stupid question, like I've overlooked something simple. My apologies if this is the case.

  2. Answer
    Stefan
    Admin
    Stefan avatar
    264 posts

    Posted 17 Sep Link to this post

    Hello Grant,

    There are two reasons for the issue.

    1) In the demo example is used dataSource.view(), not the dataSource.data(). The result from both methods is different:

    http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#methods-view

    http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#methods-data

    2) When the optionLabel is used, the dropdown item index will increase by 1 which is changing the item index by 1.

    http://docs.telerik.com/kendo-ui/api/javascript/ui/dropdownlist#methods-select

    I modified the provided example to work as expected:

    http://dojo.telerik.com/AfUga

    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.
     
  3. Kendo UI is VS 2017 Ready
  4. Grant
    Grant avatar
    41 posts
    Member since:
    Jul 2016

    Posted 19 Sep in reply to Stefan Link to this post

    Hi Stefan, 

    Thanks for the help. My problem was that I didnt take into account that 'OptionLabel' would count as an <option>, very silly.

    Thanks again,
    Grant

Back to Top