client side:ComboBox: Select item in disabled comboBox

4 posts, 0 answers
  1. Taraman
    Taraman avatar
    17 posts
    Member since:
    Aug 2010

    Posted 03 Jan 2011 Link to this post

    Hello Telerik,
    I have a problem when dealing with RadComboBox.
    if the comboBox is disabled, and I want to select an item it doesn't work

    the following not working:

    ComboBoxTitle.disable();
    ComboBoxTitle.findItemByValue("2").select();

    the problem is the combo may be disable or not before selecting item so I make the following workaround

    if (!ComboBoxTitle.get_enabled()) {
        ComboBoxTitle.enable();
        ComboBoxTitle.findItemByValue(ContactData.TitleId).select();
        ComboBoxTitle.disable();
    }
    else {
        ComboBoxTitle.findItemByValue(ContactData.TitleId).select();
    }
    but I am asking if there are a better solution

    thanks,
    Taraman
  2. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 04 Jan 2011 Link to this post

    Hello Taraman,

    When a RadComboBox control is disabled - you are not able to select an item in it.
    This behaviour is correct and is by design.
    That is why you are on the right way with the approach that you use.

    Regards,
    Kalina
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Thad
    Thad avatar
    106 posts
    Member since:
    Sep 2010

    Posted 22 Dec 2011 Link to this post

    Hi Karina,

    May I ask the reason for this design decision?  Why do you not allow an item to be selected in a disabled RadComboBox?  That seems very counter-productive, and I spent several hours today trying to figure out why some JavaScript was not working as expected.

    Here is the code from your library which clearly illustrates that the select code is not firing if the ComboBox is disabled...
    _select: function (h) {
        if (!this.get_isEnabled() || this.get_isSeparator()) {
            return;
        } var c = this.get_comboBox();
        if (c.raise_selectedIndexChanging(this, h) == true) {
            return;
        } var i = c.get_text();
        var g = c._getLastSeparatorIndex(i);
        var j = i.substring(0, g + 1) + this.get_text();
        var d = c.get_selectedItem();
        if (d) {
            d.set_selected(false);
        } c.set_text(j);
        c.set_originalText(j);
        c.set_value(this.get_value());
        c.set_selectedItem(this);
        c.set_selectedIndex(this.get_index());
        this.set_selected(true);
        this.highlight();
        c.raise_selectedIndexChanged(this, h);
        var f = { Command: "Select", Index: this.get_index() };
        c.postback(f);
    }

    Thanks for helping me understand.

    Happy Holidays!
    Thad
  5. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 28 Dec 2011 Link to this post

    Hi Thad,

    Can you explain the scenario that you want to implement in more details?
    Why do you need to set a selected item within a disabled RadComboBox?
    Maybe with more details about your implementation we will be able to suggest you a solution?

    Regards,
    Kalina
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top