I've got trouble using the disableEvents function of the RadComboBox.
When I add a RadComboBox to my ASP.NET page, with the OnClientSelectedIndexChanged and OnClientItemsRequested event handler. To preselect a item in the combobox, I first lookup the item in the itemcollection. If the item is found, I execute disableEvents() on the combobox, select the item and after that, reenable the events with enableEvents().
Directly after I select the item, the OnClientSelectedIndexChanged-event is triggered. Because of the disableEvents() I don't expect the event to be triggered.
The following code demonstrates the bug:| <script type="text/javascript"> |
| function onrequested(sender, eventArgs) { |
| sender.disableEvents(); |
| sender.get_items().getItem(0).select(); |
| sender.enableEvents(); |
| } |
| function onchange(sender, eventArgs) { |
| alert("changed! new value: " + sender.get_value()) |
| } |
| </script> |
| <script runat="server"> |
| Protected Sub cmbItemsRequested(ByVal sender As Object, ByVal e As EventArgs) |
| cmb.DataSource = New object() {New with { .Text="Text1"}, New with { .Text = "Text2"}} |
| cmb.DataBind() |
| End Sub |
| </script> |
| <telerik:RadComboBox HighlightTemplatedItems="True" DataTextField="Text" DataValueField="Text" EnableLoadOnDemand="true" OnItemsRequested="cmbItemsRequested" runat="server" id="cmb" OnClientSelectedIndexChanged="onchange" OnClientItemsRequested="onrequested"> |
| <ItemTemplate>(<%# DataBinder.Eval(Container, "Text") %>)</ItemTemplate> |
| </telerik:RadComboBox> |