Making a field read-only in the view

Hi

Another basic question I'm afraid...

I'm trying to force an int field to read only (dependent upon various conditions). However, I'm not having any luck. Is there a way to either alter the vardef metadata in a view (custom edit view) - or by altering the model?

I've had various attempts such as:

                this.fields[testArrayIndex].action="disabled";

                this.fields[testArrayIndex].def.readonly=true;

                this.fields[testArrayIndex].fieldDefs.readonly = true;

 

where testArrayIndex is the index for the field in question. The above is what appears to be set when the main field metadata has readonly = true defined. However, as I want this to be conditional on the state of the app, I can't use the server metadata for this.

 

Thanks