In our application, we have the requirement to display the DropDownList's filter textBox only if there are more than a specific number of items in the DropDownList. Therefore, we count the items everytime they change (i.e. an item is added/removed or perhaps all items are replaced) and then update the DropDownList's filter setting accordingly via setOptions().
Additionally, we use the dataBound() event for internal UI tweaks and therefore access the e.sender object.
This DOJO demonstrates that e.sender has a different structure before and after setOptions() is called. For instance, the list property does no longer exist. Check the console output, the event object is logged every time dataBound() is called.
Interestingly, this only happens when passing a complete (but updated) object to setOptions() and not when passing only a partial options object. Still, re-setting options to the same value as before should not interfere with any event args.
Hi Michael,
I must agree that the setOptions() method description needs improvement, so that it explains the cases in which manual rebind of events is needed. That is why I have logged an item for documentation improvement.
As a small token of gratitude for suggestion the above I have updated your Telerik points.
Regards,
Veselin Tsvetanov
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.
Thank you for the clarification. Maybe it should somehow be mentioned in the documentation that you need to rebind manually?
Especially since the documentation states
In some cases, the setOptions
method can recreate and rebind the widget instance.
which implies that a rebind would happen automatically and that's the caveat. In this case, however, a developer needs be careful because a rebind does not take place.
Hi Michael,
The issue observed is caused by the fact that the dataBound event handler is reassigned to the DropDownList widget instance. In order to keep event calls and their arguments in order, please remove all handlers from the options object:
delete updatedOptions.dataBound
If you still need to re-assign an event handler you should do it using unbind() and bind() method calls:
dropDownList.unbind("dataBound")
dropDownList.bind("dataBound", function(e) {
console.log(e.sender.list);
});
Here is a modified version of the sample discussed implementing the above suggestion:
https://dojo.telerik.com/uBAKomIs/2
I hope that the above explains the case. If you have any other questions, please do not hesitate to contact us.
Regards,
Veselin Tsvetanov
Progress Telerik