Search code examples
extjsgridselectionextjs6-classic

How to select a record by clicking one cell in a grid ExtJS 6


I have a grid and i want to select the whole record by clicking one specific cell. The problem is i cant use the checkboxmodel seltype, cause i want to show a custom icon on every cell. So is there any way to make it possible?


Solution

  • I solved the problem with the beforecellclick event. Now it looks like this:

    beforecellclick:function(grid,record,index){
                            if(index != 0){
                                return false
                            }
                   }
    

    and I have an action column on colIndex 0:

    xtype: 'actioncolumn',
            tooltip:'löschen',
            width: 30,
            icon: '../../../../../../resources/images/16/delete_2.png',
            handler:function(grid, rowIndex, colIndex){
                var record = grid.getStore().getAt(rowIndex);
                if( grid.getSelectionModel().isSelected(record) == false){
                    grid.getSelectionModel().select(record, true)
                }else{
                    grid.getSelectionModel().deselect(record)
                }      
            }