Disable comboxes using jquery

9 posts, 1 answers
  1. John Giblin
    John Giblin avatar
    155 posts
    Member since:
    Jan 2006

    Posted 20 Nov 2012 Link to this post

    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');
  2. Answer
    Kevin
    Kevin avatar
    360 posts
    Member since:
    Jul 2012

    Posted 20 Nov 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 Nov 2012 Link to this post

    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.
  5. Ivan Zhekov
    Admin
    Ivan Zhekov avatar
    539 posts

    Posted 21 Nov 2012 Link to this post

    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.
  6. John Giblin
    John Giblin avatar
    155 posts
    Member since:
    Jan 2006

    Posted 21 Nov 2012 Link to this post

    I was actually trying to disable them all on the forms. I not just one
  7. John Giblin
    John Giblin avatar
    155 posts
    Member since:
    Jan 2006

    Posted 21 Nov 2012 Link to this post

    that didnt work.
  8. Ivan Zhekov
    Admin
    Ivan Zhekov avatar
    539 posts

    Posted 22 Nov 2012 Link to this post

    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.
  9. Deepak
    Deepak avatar
    6 posts
    Member since:
    Dec 2012

    Posted 08 May 2014 in reply to Ivan Zhekov Link to this post

    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.
  10. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 08 May 2014 in reply to Deepak Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017