Can a webcombo be made to be readonly so that a user cannot change the value it contains?
Thanks,
Dave
Hi Dave,
I just ran into a similar yet simpler problem and could not find any suggestion by either Infragistics support or other developers. I just wanted to make some webcombo controls on my screen readonly (or disabled) based on the selected value of a controlling webcombo - so the selected value of a particular webcombo causes some predefined fields to become readonly to the user, and this must be done on the client without a roundtrip to the server.
I want to share with you and others the following solution that I came up with just a short while ago... This solution will work along with the styleset assigned to the control (if used) and will even properly utilize styles assigned to the disabled state if you have added such state style to your styleset css files (customized css).
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 itfunction 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 ClientUniqueId "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 or unset the disabled attributes on these elements and we have our intended behavior.I hope this helpsAli M
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 itfunction 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'); } }};
I would like to point out that I have this problem sorted with no problems, I have populated the combo with ONE selection for a certain security group and populate the combo with all other selections for other security groups, this means the restricted user can see (black text) the option and select it but can not change it and other users can see and select the other options, hope this work around helps.
If you would read the documentation installed on your computer or you would search this forum, you will discover that
Infragistics controls have a JavaScript-based object model, also known as a client-side object model (CSOM)
No.
Error 3 'inputBox' is not a member of 'Infragistics.WebUI.WebCombo.WebCombo'.
If you want to make the webcombo textbox readonly, then do this :
webCombo.inputBox.readOnly = true;
If you want to disable the webcombo, then do this:
webCombo.Element.disabled = true;