PDA

View Full Version : Help: setValue override for DisplayField is not working



pavanextjs
24 Mar 2010, 5:48 AM
Hi All,

We are using ExtJS 3.1 and i was trying to override the 'setValue' method of Ext.form.DisplayField as we need to append the special symbols based on the type of data coming (something similar to USMoney/Percentage/Whole Number).

It is not working and the display fields are empty.


Ext.override(Ext.form.DisplayField, {
//private
setValue : function(v){
if(this.dataType) { //this is a custom config option we will give
console.log('dataType: ' + this.dataType + ', Value: ' + v);
}
var value = String(v) + ' Test'; //for testing, append ' Test' to the value
console.log('New Value: ' + value);

//call the parent with the new value
Ext.form.DisplayField.superclass.setValue.call(this, value);
}
});If i try to override the same 'setValue' of Ext.form.TextField, it is working fine and all TextFields are having the text 'Test' appended to their value.

Am i missing something with the DisplayField?

Thanks in advance.

pavanextjs
24 Mar 2010, 10:12 AM
Can somebody help me with this please !

tunky
24 Mar 2010, 9:46 PM
You may need to check the source code before override it:

In DisplayField

setValue : function(v){
this.setRawValue(v);
return this;
}


So , please try:

Ext.override(Ext.form.DisplayField, {
setValue : function(v){
this.setRawValue(v+'Test');
return this;
}
});

Animal
24 Mar 2010, 10:08 PM
Maybe you can find some help here: http://www.extjs.com/forum/showthread.php?t=62951

pavanextjs
25 Mar 2010, 7:41 AM
Thank you so much guys !