开发者

Render link in Grid cell with custom "click" handler

开发者 https://www.devze.com 2023-03-03 15:56 出处:网络
I am rendering a custom link in ExtJS Grid via my own renderrer: function renderLink( val ) { return \'<a href=\"javascript:void(0);\">\' + val + \'</a>\';

I am rendering a custom link in ExtJS Grid via my own renderrer:

function renderLink( val ) {
    return '<a href="javascript:void(0);">' + val + '</a>';
}
开发者_Python百科

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

Of course after all rows in grid are rendered I could iterate through every record from the grid store and on each of it:

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

But for me it sounds rather workaround than real solution... Is there any better way?


Try this:

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


You can attach click event for example with dblclick listener:

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


            },
            element: 'body'
        }
    }

All columns values can be seen by console.log(selectedRecord):

0

精彩评论

暂无评论...
验证码 换一张
取 消