Why does clicking icon in an ExtJS 4 grid panel actioncolumn not select the row?

StackOverflow https://stackoverflow.com/questions/21325290

  •  02-10-2022
  •  | 
  •  

I have a grid panel with an actioncolumn.

There is an icon in the actioncolumn, and its click handler works fine.

But when I click the icon, in the click handler I want to access the selected row, but it seems no row is selected.

Is this expected? Do I need to manually set the selected row when an actioncolumn icon is clicked?

没有正确的解决方案

其他提示

If you want to select row also after user click on icon in actioncolumn just set actioncolumn stopSelection config property to false:

{    
    xtype:'actioncolumn',
    stopSelection: false,
    items: [{
       ...
    }]
}

However common use case how to access row's record when user click on icon in action column is get index of the row where user click on the action column icon and get record from store at this index:

{
    xtype:'actioncolumn',
    items: [{
        tooltip: 'Edit',
        handler: function(grid, rowIndex, colIndex) {
            // get record at index of row where user click on icon in action column
            var record = grid.getStore().getAt(rowIndex);
            // do action with record ...
        }
    }]
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top