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

RadCombobox cannot set selectedIndex in jQuery

3 Answers 226 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
RMM
Top achievements
Rank 1
RMM asked on 11 Aug 2015, 12:39 PM

Hi

I'm trying to use jquery to update a RadCombobox and set its selected index by using RadComboboxItem.Select().

The updating works fine, but when I use RadComboboxItem.Select() where RadComboboxItem.get_index()=0, RadCombobox.get_selectedIndex() returns the old index.

If RadCombobox.get_index()>0 it works fine.

 

 function SetSelection(radCombo, selectedValue) {
radCombo.trackChanges();
radCombo.clearSelection();
var item = radCombo.findItemByValue(selectedValue);
if (item != null) {
item.select();
alert("id=" + radCombo.get_id() + " item.index=" + item.get_index());
radCombo.set_text(item.get_text());
radCombo.set_value(item.get_value());
}
radCombo.updateClientState();
radCombo.commitChanges();
alert("id="+radCombo.get_id()+" selectedValue="+selectedValue+" index=" + radCombo.get_selectedIndex());
}

 

3 Answers, 1 is accepted

Sort by
0
RMM
Top achievements
Rank 1
answered on 11 Aug 2015, 12:52 PM

Hi Again.

I've just found out, get_selectedIndex is not working when RadComboboxItem.get_index()>0 either.

Or could it be RadComboboxItem.select() that isn't working?

0
RMM
Top achievements
Rank 1
answered on 12 Aug 2015, 06:26 AM

I've found the answer myself.

The index was prevented from changing because I had an onClientIndexChanging handler with args.set_cancel(false), if I was handling the clientIndexChange of another RadComboBox.

0
Eyup
Telerik team
answered on 13 Aug 2015, 02:23 PM
Hello Rene,

I'm glad you've managed to root out the problem by yourself. Please note that in such cases, it is of tremendous help to disable any AJAX on the page if present (RadAjaxManager, RadAjaxPanel, UpdatePanel, etc.). Then you can enable your script debugger (FireBug or F12) to see whether there are any errors interfering. When AJAX is enabled, the errors are being hidden or encapsulated, which may lead to omission.

For additional client-side examples using the Telerik API, you can refer to our documentation articles:
http://docs.telerik.com/devtools/aspnet-ajax/controls/combobox/radcombobox-items/working-with-items-in-client-side
http://docs.telerik.com/devtools/aspnet-ajax/controls/combobox/client-side-programming/overview

Hope this helps.

Regards,
Eyup
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Ajax
Asked by
RMM
Top achievements
Rank 1
Answers by
RMM
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or