The motivation is to render cell grid as a clickable anchor using template,
The two implementation that suggested are:
1. Within the cell renderer function create a fly component to hold the data and provide ID to access that data,
Her the code:
This is to avoid re-scan the whole components using afterrender function, and still to be able to call services (functions) belong to the view controlCode:renderer: function(value, metaData, record, rowIndex, colIndex, store, view) { var ctrl = this.getController(); var cmp = new Ext.Component({ listeners: { click: function(){ ctrl.editTemplateClick(record); } }, }); // disposing the fly component this.on('destroy', function() { cmp.destroy(); }); return Ext.String.format('<a href="#" onclick="Ext.getCmp(\'{0}\').fireEvent(\'click\'); return false;">XXX</a>', cmp.id); }
the second approach,
2. Within the cell renderer function return anchor, than scan the grid in afterrender function
Code:renderer: function(value, metaData, record, rowIndex, colIndex, store, view) { return Ext.String.format('<a href="#" data-id="{0}" class="trainLink">Train</a>', record.data.Id); },Code:afterrender: function(component, eOpts) { component.getEl().on('click', function(ev, elem) { var id = parseInt(elem.getAttribute('data-id')); var record = this.component.getStore().getById(id); }, null, { delegate: 'a.trainLink' }); },