Search code examples
javascriptextjsgridsencha-architect

Ext JS grid get dom of last selected row


Is there any chance to get the DOM values of the last selected row inside a grid. I could only get the record with values and not the DOM elements. With DOM elements I mean the <tr> element of the row selected.

var selectedRecord = grid.getSelectionModel().getLastSelected();

//only gets the model instance that is selected


Solution

  • You can use grid's view getNode() method. It returns HTMLElement of the grid record's row. If you want to do something with row HTML element you can use Ext.get() method to obtain Ext.dom.Element object.

    // selected record
    var selectedRecord = grid.getSelectionModel().getLastSelected();
    
    // row HTMLElement
    var node = grid.view.getNode(selectedRecord);
    
    // Ext.dom.Element object
    var el = Ext.get(node);