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