PDA

View Full Version : How to combine XTemplate and custom renderer? in RowExpander



mikhailt
19 Aug 2011, 4:28 AM
I use RowExpander plugin with a template.
How to use renderer function in the template?


REDrenderer = function(nValue)
{
var retValue = nValue;
if (nValue < threshold)
{
retValue = "<font style='color:red;'>" + nValue.toString() + "</font>";
}
return retValue;
};


Ext.create('Ext.grid.Panel', {
store: mystore,
columns: [
{
header : 'AAA',
dataIndex: 'aaa1',
renderer: REDrenderer
}
],

plugins: [
{
ptype: 'rowexpander',
rowBodyTpl : [ '<div>{aaa1}</div>' ] //NEED to call REDrenderer() here!
}
]
});

I want to see value red in expanded template using defined renderer.

stevil
19 Aug 2011, 7:01 AM
Try:



// sorry, just prefer not to declare global functions if I can avoid it!
var app = {};
app.REDrenderer = function(nValue)
{
var retValue = nValue;
if (nValue < threshold)
{
retValue = "<font style='color:red;'>" + nValue.toString() + "</font>";
}
return retValue;
};




Ext.create('Ext.grid.Panel', {
store: mystore,
columns: [
{
header : 'AAA',
dataIndex: 'aaa1',
renderer: app.REDrenderer
}
],


plugins: [
{
ptype: 'rowexpander',
rowBodyTpl : '<div>{[app.REDrenderer(values.aaa1);]}</div>'
}
]
});



stevil