Cant add and select newly added element

2 posts, 1 answers
  1. Jakub
    Jakub avatar
    24 posts
    Member since:
    Jun 2015

    Posted 30 Apr 2016 Link to this post


    I have a problem with DropDownList. If you try to open ddl, filter by "me", select it and then click button "clickme" the newly added item isnt selected.


  2. Answer
    Dimo avatar
    8407 posts

    Posted 03 May 2016 Link to this post

    Hello Jakub,

    Adding a custom data item programmatically and selecting it is not supported with server filtering enabled and here is why.

    When server filtering is enabled, the dropdown shows only items, which match the filtering criteria, i.e. what the user has typed. If a new value is set programmatically, the filtering criteria should be cleared:

    var ddl = angular.element("#ddl").data("kendoDropDownList");
    ddl.dataSource.add({Id: 1, Name: "wow"});
    $scope.myModel = 1;

    However, if the filter state is cleared and a new value is set programmatically, the DropDownList will try to reload its data the next time it is opened, so that it can display the new value in the context it exists (e.g. all other items, and not the previous subset of filtered items). This data reload will cause the custom data item and custom value to be lost.

    There are two ways to proceed:

    - do not use server filtering, so that the DropDownList does not make remote requests, which clear the custom data item and value
    - add the custom data item server-side, instead of client-side, so that it can be loaded together with the other data items

    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top