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

Disable comboxes using jquery

8 Answers 941 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
John Giblin
Top achievements
Rank 1
John Giblin asked on 20 Nov 2012, 03:53 PM
I am able to disable the options by
$(".RadComboBoxDropDown").attr('disabled','disabled');

I thought I would be able to make the combobox readonly/disabled but doing the following but it is not working.
$(".RadComboBox").attr('disabled','disabled');

8 Answers, 1 is accepted

Sort by
0
Accepted
Kevin
Top achievements
Rank 2
answered on 20 Nov 2012, 09:58 PM
Hello John,

The RadComboBox has a jQuery object created on the client-side. In order to disable it, you need to call the disable() function. To enable it, you call the enable() function.

Like so:
var combo = $find("<%=RadComboBox1.ClientID%>");
combo.disable();

I hope that helps.
0
Shinu
Top achievements
Rank 2
answered on 21 Nov 2012, 05:30 AM
Hi John,

You can disable the input area of the RadComboBox using the following JQuery.

JS:
$(".rcbInput").attr('disabled', 'disabled');

Hope this helps.

Regards,
Shinu.
0
Ivan Zhekov
Telerik team
answered on 21 Nov 2012, 12:54 PM
Hello,

The answer provided by Kevin is the correct one, while the one provided by Shinu answers the questions in the realm of jQuery. Let me explain.

Finding the combobox input with jQuery is no issue and, like Shinu showed, it takes one line. I should not that this exact snippet will disable all inputs of comboboxes on the page, not just one.

However, simply disabling the input may not always be the thing you want. Not to mention there is certain logic in the control (methods, states) that is not activated when using this method. Thus, even though the actual input will look disabled, the control will not know about it, styles wont be applied, events won't be discarded.

And this is why Kevin's answer is the correct one.

All the best,
Ivan Zhekov
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.
0
John Giblin
Top achievements
Rank 1
answered on 21 Nov 2012, 01:10 PM
I was actually trying to disable them all on the forms. I not just one
0
John Giblin
Top achievements
Rank 1
answered on 21 Nov 2012, 05:09 PM
that didnt work.
0
Ivan Zhekov
Telerik team
answered on 22 Nov 2012, 01:17 PM
Hi, John.

In order to disable all comboboxes you need to use a combination of both snippets:

function pageLoad() {
 
    // assuming that $ is jQuery
    $( ".RadComboBox" ).each(function() {
 
        // this refers to the element
        var combo = $find( this.id );
        combo.disable();
 
    });
}


Regards,
Ivan Zhekov
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.
0
Deepak
Top achievements
Rank 2
answered on 08 May 2014, 09:46 AM
How can I disable only one specific item in the rad combo box list? Actually I want to make one specific item selected which is the mandatory and user cannot deselect, however user can select other available options.
0
Shinu
Top achievements
Rank 2
answered on 08 May 2014, 10:26 AM
Hi Deepak,

Please try the following JavaScript to disable the Item in a RadComboBox.

JavaScript:
<script type="text/javascript">
    function pageLoad() {
        var combo = $find("<%=radcboDisableItem.ClientID %>");
        combo.findItemByText("Item2").disable(); // accessing the item by text and making it as disable
    }
</script>

Thanks,
Shinu.
Tags
ComboBox
Asked by
John Giblin
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 2
Shinu
Top achievements
Rank 2
Ivan Zhekov
Telerik team
John Giblin
Top achievements
Rank 1
Deepak
Top achievements
Rank 2
Share this question
or