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

Programmatic selection and change

2 Answers 327 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 17 Jan 2013, 05:56 PM
For the case of user based selection of an item, the change event is fired.

For the case of programmatic selection by way of select(), value() or search() it appears that the change event is not fired. 
Q: Is this a design feature ?
Q: If yes, would there be any reason not to use a programmatic _change() after the selection?

2 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 21 Jan 2013, 09:10 AM
Hello Richard,

 
Up to your questions:

#1:
Yes, this behavior is by design. When then value is changed using the API, the change event should not be raised. If you need to trigger the change event use:

$("#widgetID").data("kendoDropDownList").trigger("change");

Please note that the search() method just changes the focused item. Hence when the widget looses focus the change event will be raised.

#2:
I am not exactly sure that I understand the quetion, but I suppose that you are asking why the _change method is not called after a programmatic seleciton. The _change method actually controls when the change event should be triggered. It will be called only when the value is changed by user interaction. Please elaborate more on the question if I am missing something.
Regards,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Richard
Top achievements
Rank 1
answered on 21 Jan 2013, 12:51 PM
Hi Georgi:

Thanks for the clarification.

The question #2 was really about forcing the change event, which you cleanly answered in #1 with .trigger() .

Regards,
Richard
Tags
DropDownList
Asked by
Richard
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Richard
Top achievements
Rank 1
Share this question
or