-
19 Aug 2011 4:28 AM #1
Answered: How to combine XTemplate and custom renderer? in RowExpander
Answered: How to combine XTemplate and custom renderer? in RowExpander
I use RowExpander plugin with a template.
How to use renderer function in the template?
I want to see value red in expanded template using defined renderer.Code: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! } ] });
-
Best Answer Posted by stevil
Try:
Code:// 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
-
19 Aug 2011 7:01 AM #2
Try:
Code:// 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



Reply With Quote