Search code examples
extjsextjs4.2extjs-grid

Get the focussed row (not the selected)


I have a grid, with a selection model that does allow the selection of a row only under certain conditions.

When I click on a row, it gets focussed (it becomes darker gray). I want to add a button, that acts on the currently focussed row.

Since the selection is deactivated, I cannot use the normal way

grid.getSelectionModel().getSelection()

because there is no selection. How can I access the focussed row ?


Solution

  • Add this listener to your grid to get information about the focused row.

    Ext.create('Ext.grid.Panel', {
        ...
        listeners: {
            afterrender: function(component){
                component.getSelectionModel().on({
                    focuschange: function (view, oldFocused, newFocused, eOpts) {
                        console.log(newFocused);
                    }
                });
            }
        }
    });