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

client side:ComboBox: Select item in disabled comboBox

3 Answers 151 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Taraman
Top achievements
Rank 1
Taraman asked on 03 Jan 2011, 01:01 PM

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

3 Answers, 1 is accepted

Sort by
0
Kalina
Telerik team
answered on 04 Jan 2011, 05:20 PM
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.
0
Thad
Top achievements
Rank 2
answered on 22 Dec 2011, 11:58 PM
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
0
Kalina
Telerik team
answered on 28 Dec 2011, 10:32 AM
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
Tags
ComboBox
Asked by
Taraman
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Thad
Top achievements
Rank 2
Share this question
or