Hi,
We have a dynamic form in which we'd like, under certain circumanstances (e.g., user is in "Read-Only" mode), to disable editing of all the formitems. We tried a number of obvious solutions but they didn't work. Any assistnace is much appreciated. It seems like this should be relatively easy to do...
Attempt #1:
==============
We tried to set all FormItems to "StaticTextItem". This did prevent editing, but it had problems: boolean fields were changed from a checkbox look to a field with a string value of "true" or "false"; worse, combobox item's value ID values were shown instead of the actual display text. (That is, if the field's ds read like this:
<field name="optionEX" title="Sample enzyme" type="text"
length="255" section="General" simple="true" required="true">
<valueMap>
<value ID="-eT">Trypsin</value>
<value ID="-eS">StrictTrypsin</value>
<value ID="-eC">Chymotrypsin</value>
<value ID="-eR">RalphTrypsin</value>
<value ID="-eA">AspN</value>
<value ID="-eG">GluC</value>
<value ID="-eB">GluC Bicarb</value>
<value ID="-eM">CNBr</value>
<value ID="-eD">Trypsin/CNBr</value>
<value ID="-e3">Chymotrypsin/AspN/Trypsin</value>
<value ID="-eE">Elastase</value>
<value ID="-eK">LysC / Trypsin_K (cuts after K not before P)
</value>
<value ID="-eL">LysN (cuts before K)</value>
<value ID="-eP">LysN Promisc (cuts before KASR)</value>
<value ID="-eN">Nonspecific or None</value>
</valueMap>
</field>
then, when we set the fields to be StaticTextItem, it showed the id value of say "-eT" instead of the value "Trypsin".
Attempt #2:
===============
We tried to disable the formitem using this command:
currentFormItem.disable();
However, this greyed out the formitem label, removed the formitem icon (and also made it unclicable), and (as I recall) also made the actual formitem value values unclickable.
Attempt #3:
==================
We then tried to set the field's canEdit property to false as follows:
currentFormItem.setAttribute("canEdit", "false") ;
We also tried:
currentFormItem.setAttribute("canEdit", false) ;
But this did not seem to have any effect.
So our question is: what's the best way to prevent a user from making any changes to a formitem, yet still preserver all other features (e.g., the label should appear in its normal color; the formitem icon should appear and still be clicable; for those formitems that have drop-downs, the formitems values should appear, and not the value ID; and ideally, the user can still click on the form item's drop down box to see the other options, but will NOT be allowed to make any changes. Finally, as a bonus, it'd be nice if the color background of the formitem were to change, (eg become grey) to indicate that the field is no longer editable.)
(FYI: Although I don't think it's relevant, we're "constructing" our dynamic form by creating CheckboxItems, TextItems, FloatItems etc. and then adding it to the dynamic form by calling setFiedlds.)
Additional infracstructure details are below:
==================================================
OS: Windows XP Pro
IDE: MyEclipse 9.0 with Google Plugin for Eclipse (2.3.1)
SmartGWT EE 2.4
Browwer: Mozilla Firefox 4.0.1
GWT SDK: 2.2
Sun JDK 1.6.0_13
We have a dynamic form in which we'd like, under certain circumanstances (e.g., user is in "Read-Only" mode), to disable editing of all the formitems. We tried a number of obvious solutions but they didn't work. Any assistnace is much appreciated. It seems like this should be relatively easy to do...
Attempt #1:
==============
We tried to set all FormItems to "StaticTextItem". This did prevent editing, but it had problems: boolean fields were changed from a checkbox look to a field with a string value of "true" or "false"; worse, combobox item's value ID values were shown instead of the actual display text. (That is, if the field's ds read like this:
<field name="optionEX" title="Sample enzyme" type="text"
length="255" section="General" simple="true" required="true">
<valueMap>
<value ID="-eT">Trypsin</value>
<value ID="-eS">StrictTrypsin</value>
<value ID="-eC">Chymotrypsin</value>
<value ID="-eR">RalphTrypsin</value>
<value ID="-eA">AspN</value>
<value ID="-eG">GluC</value>
<value ID="-eB">GluC Bicarb</value>
<value ID="-eM">CNBr</value>
<value ID="-eD">Trypsin/CNBr</value>
<value ID="-e3">Chymotrypsin/AspN/Trypsin</value>
<value ID="-eE">Elastase</value>
<value ID="-eK">LysC / Trypsin_K (cuts after K not before P)
</value>
<value ID="-eL">LysN (cuts before K)</value>
<value ID="-eP">LysN Promisc (cuts before KASR)</value>
<value ID="-eN">Nonspecific or None</value>
</valueMap>
</field>
then, when we set the fields to be StaticTextItem, it showed the id value of say "-eT" instead of the value "Trypsin".
Attempt #2:
===============
We tried to disable the formitem using this command:
currentFormItem.disable();
However, this greyed out the formitem label, removed the formitem icon (and also made it unclicable), and (as I recall) also made the actual formitem value values unclickable.
Attempt #3:
==================
We then tried to set the field's canEdit property to false as follows:
currentFormItem.setAttribute("canEdit", "false") ;
We also tried:
currentFormItem.setAttribute("canEdit", false) ;
But this did not seem to have any effect.
So our question is: what's the best way to prevent a user from making any changes to a formitem, yet still preserver all other features (e.g., the label should appear in its normal color; the formitem icon should appear and still be clicable; for those formitems that have drop-downs, the formitems values should appear, and not the value ID; and ideally, the user can still click on the form item's drop down box to see the other options, but will NOT be allowed to make any changes. Finally, as a bonus, it'd be nice if the color background of the formitem were to change, (eg become grey) to indicate that the field is no longer editable.)
(FYI: Although I don't think it's relevant, we're "constructing" our dynamic form by creating CheckboxItems, TextItems, FloatItems etc. and then adding it to the dynamic form by calling setFiedlds.)
Additional infracstructure details are below:
==================================================
OS: Windows XP Pro
IDE: MyEclipse 9.0 with Google Plugin for Eclipse (2.3.1)
SmartGWT EE 2.4
Browwer: Mozilla Firefox 4.0.1
GWT SDK: 2.2
Sun JDK 1.6.0_13
Comment