Render link in a Grid cell with a custom "click" handler

I create a custom link in ExtJS Grid through my own renderrer:

function renderLink( val ) { return '<a href="javascript:void(0);">' + val + '</a>'; } 

What is the easiest way to connect a click event listener to it?

Of course, after displaying all the rows in the grid, I could iterate over each record from the grid storage and over each of them:

 Ext.get('....').on('click', ....); 

But for me this sounds more like a workaround than a real solution ... Is there a better way?

+4
source share
2 answers

Try the following:

 function renderLink( val ){ return '<a href="javascript:void(0);" onclick="someMethod(); return false;">' + val + '</a>'; 
0
source

You can attach a click event, for example, while listening to dblclick:

 listeners: { dblclick : { fn: function() { var selectedRecord = Ext.getCmp('ObjectsGrid').getSelectionModel().getSelection()[0]; console.log(selectedRecord); }, element: 'body' } } 

All column values ​​can be seen using console.log (selectedRecord):

0
source

All Articles