PDA

View Full Version : Ext.override readOnly



ricarline
16 Jul 2009, 8:22 AM
Do I risk to have bugs with this code?



//Add function to Field and all class which extend from it.
Ext.override(Ext.form.Field, {

// Block user to change value of a field
R : function(){
document.getElementById(this.id).readOnly=true;
},

// Allow user to change value of a field
RW : function(){
document.getElementById(this.id).readOnly=false;
},

});

tryanDLS
16 Jul 2009, 1:37 PM
You really think that's a good API to have to code to? Can you make it any more cryptic?



Ext.override(Ext.form.Field, {
setReadOnly : function(readOnly){
this.el.dom.readOnly = readOnly === true;
}
})


Note that this will probably not do what you want on the more complex descendants of Field and will need more work.

ricarline
21 Jul 2009, 7:43 AM
thx for answers

tryanDLS I just understand what you mean, my function don't permit me to set a checkbox to read only :(

Do you have an idea on the way to do it?