Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
350
Disable WebCombo using Javascript
posted

How do I disable and enable the WebCombo (version 9.1.20091.1015) using javascript?

I have already tried combocontrol.setEnabled(false) and that did not work

Parents
  • 105
    posted

    While there is no direct method of disabling the webcombo control from Javascript (Infragistics dropped the ball here!), I figured a method to successfully accomplish it.  Unlike other suggested methods I have seen here in the forums, this method works in both IE and Firefox, and follows the currently used styleset css - I had modified my css files to follow a certain color scheme for the site.

     

    if (IwantToDisableCombo)
        EnableDisableCombo(_id, false);
    else
        EnableDisableCombo(_id, true);   


    // comboid:  the id of the webcombo (clientid) as seen by the browser in Javascript
    // state: whether you want to enable or disable the webcombo control.  Passing true Enables it, while passing false Disables it
    function EnableDisableCombo(comboid, state) {
        var _ctl = igcmbo_getComboById(comboid);
        if (_ctl) {
            if (state == true) {
                var _maindiv = $get(_ctl.ClientUniqueId + '_Main');
                if (_maindiv)
                    _maindiv.removeAttribute('disabled');
                var _inputctl = $get(_ctl.ClientUniqueId + '_input')
                if (_inputctl)
                    _inputctl.removeAttribute('disabled');
            }
            else {
                var _maindiv = $get(_ctl.ClientUniqueId + '_Main');
                if (_maindiv)
                    _maindiv.setAttribute('disabled', 'disabled');
                var _inputctl = $get(_ctl.ClientUniqueId + '_input')
                if (_inputctl)
                    _inputctl.setAttribute('disabled', 'disabled');
            }
        }
    };

     

    As you can see, I am searching for two items that are auto-generated at runtime by the control and sent to the browser.  These items are named using the webcombo's ClientUniqueId with either "_Main" or "_input" appended to it. As an example, if the webcombo control has the following ClientId "ctl00xContentPlaceHolder1xtabItemxctl00xxxctlx6" (mine is several layers down the hierarchy), then the html elements you are looking for have the following Ids "ctl00xContentPlaceHolder1xtabItemxctl00xxxctlx6_Main" and "ctl00xContentPlaceHolder1xtabItemxctl00xxxctlx6_input".  We only need to set and unset the disabled attributes on these elements and we have our intended behavior.

     

    I hope this helps

    Ali M

     

Reply Children
No Data