PDA

View Full Version : getValue on Ext.extend



wki01
2 Jul 2009, 1:43 AM
I think this is a bug, but I'm not sure, since it does not work even with the 2.2.1
If I extend getValue method no longer works the change event

Is there a trick to make it work? Thank you



TextField1 = Ext.extend(Ext.form.TextField, {
getValue: function() {
var v = this.value;
if(v === this.emptyText || v === undefined){
v = '';
}
return v;
}
})

Ext.onReady(function() {
new TextField1({ applyTo: "ID_Stato" ,
listeners: {
change: function(field, value){
alert("CHANGED")
}
}
})

new TextField1({ applyTo: "ID_Stato_1" ,
listeners: {
change: function(field, value){
alert("CHANGED1")
}
}
})
})

BitPoet
2 Jul 2009, 7:01 AM
this.value is only used to initialize the textfield with a value, afterwards the value is retrieved via this.el.getValue(). As this.value never changes, but the change event is only invoked in onBlur when this.getValue() returns something different from this.startValue (see the source for Ext.form.Field), it never gets triggered.

(It may seem redundant to keep this.value around when there's this.startValue, at least at first glance, but this.startValue holds the first 'real' value of the field after validation has been applied and might therefore be different)