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

[Solved] How to rerender dropdown after the entire select's HTML was changed

1 Answer 736 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Pavel
Top achievements
Rank 1
Pavel asked on 14 Sep 2014, 10:35 AM
Hi,
I have some <select> elements on my page, which are decorated with the kendoDropDownList widget.
The problem is, that their content can be changed (options can be removed, disabled or new options can be added), and I need to update the widgets' content appropriately.
I'm trying to use the refresh method, but I can't get it, new options are not present is the list.
Here is the fiddle: http://dojo.telerik.com/isAQ
Thanks.

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 16 Sep 2014, 12:08 PM
Hello Pavel,

Once the DropDownList widget is created, it does not expect its original <select> (or <input>) element to be manipulated "behind its back". The original HTML element is used by the widget only to store its value that will be submitted to the server.

If you need to change the DropDownList items, you should manipulate the widget's dataSource instance. There are two possible ways to do that.

+ replace the whole DataSource instance, if many changes are required
http://docs.telerik.com/kendo-ui/api/javascript/ui/dropdownlist#methods-setDataSource

or

+ add or remove specific items, if minor changes are required

http://docs.telerik.com/kendo-ui/api/javascript/ui/dropdownlist#fields-dataSource

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

Regards,
Dimo
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
Pavel
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or