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.
Example:
http://dojo.telerik.com/exazO/4
1 Answer, 1 is accepted
0
Accepted
Dimo
Telerik team
answered on 03 May 2016, 12:37 PM
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.filter({});
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
Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!