I just want to expand the queen3 sentence with the following trick:
editoptions: { dataInit: function(element) { $(element).attr("readonly", "readonly"); } }
Scenario # 1 :
- The field must be visible in the grid.
- The field must be visible in the form
- The field must be read-only.
Decision
colModel:[ { name:'providerUserId', index:'providerUserId', width:100,editable:true, editrules:{required:true}, editoptions:{ dataInit: function(element) { jq(element).attr("readonly", "readonly"); } } }, ],
ProviderUserId is displayed in the grid and is displayed when editing the form. But you cannot edit the content.
Scenario number 2 :
- The field should not be visible in the grid
- The field must be visible in the form
- The field must be read-only.
Decision
colModel:[ {name:'providerUserId', index:'providerUserId', width:100,editable:true, editrules:{ required:true, edithidden:true }, hidden:true, editoptions:{ dataInit: function(element) { jq(element).attr("readonly", "readonly"); } } }, ]
Note that in both cases, I use jq to reference jquery instead of the usual $. In my HTML, I have the following script to change the variable used by jQuery:
<script type="text/javascript"> var jq = jQuery.noConflict(); </script>
chris May 08 '11 at 7:41 a.m. 2011-08-08 07:41
source share