PDA

View Full Version : displayField renderer or 'load'-like event ?



drunkmoose
24 Sep 2010, 5:49 AM
Hi there!

I am trying to find something that does the same thing as for GridPanel's column renderer, but for a displayField widget instead, to no avail.

I even opened the displayField.js widget file and could not find any event in there that could let me modify the data held in it when the widget is created, like a load or create event.

Any idea how could one do this ?

Thanks,
:)

EDIT: I found this http://www.sencha.com/forum/showthread.php?62951-OPEN-640-DisplayField-to-be-able-to-format-data but I am not sure as to how to simulate a load() create() event or renderer.

StuartAshworth
24 Sep 2010, 6:04 AM
You could use set its template and control its appearance/contents that way?

drunkmoose
24 Sep 2010, 6:39 AM
Thanks, but I found this:



Ext.override(Ext.form.DisplayField, {
setValue: function(v) {
if (v.indexOf('P1') > -1) {

returnText = '<font color="red">' + v + '</font>';

}
else
{
returnText = v;
}

this.setRawValue(returnText);
return this;
}
});


Does exactly what I want. I never really got into Ext.override and it's quite useful. :)

StuartAshworth
25 Sep 2010, 6:47 AM
Be careful that this will do this logic for every displayfield in your app.