RadCombobox cannot set selectedIndex in jQuery

4 posts, 0 answers
  1. RMM
    RMM avatar
    11 posts
    Member since:
    Sep 2014

    Posted 11 Aug 2015 Link to this post

    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());
    }

     

  2. RMM
    RMM avatar
    11 posts
    Member since:
    Sep 2014

    Posted 11 Aug 2015 Link to this post

    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?

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. RMM
    RMM avatar
    11 posts
    Member since:
    Sep 2014

    Posted 12 Aug 2015 Link to this post

    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.

  5. Eyup
    Admin
    Eyup avatar
    3005 posts

    Posted 13 Aug 2015 Link to this post

    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
Back to Top