PDA

View Full Version : How to select next row in grid.



biohazardo
13 Feb 2012, 4:31 AM
Hello. After editing grid cell I need to open edit field in same cell in next row. I can't find id of selected cell. Trying that code on the Editor:

specialkey: function(field, e){

if (e.getKey() == e.ENTER) {
var grid = Ext.getCmp('sheetproductionrestin').getSelectionModel( ).getSelection();
alert(grid.get('id'));
}
}
It's answering: "Uncaught TypeError: Object [object Object] has no method 'get'". How can I take id, select next row and open editor there? Help, please

mitchellsimoens
13 Feb 2012, 4:53 AM
getSelection() will return an array.

biohazardo
13 Feb 2012, 4:54 AM
If i have info from .getLastSelected(); how can i select next row?

vietits
13 Feb 2012, 5:16 AM
var store = grid.getStore();
var selModel = grid.getSelectionModel();
var selectedRecord = selModel.getLastSelected();
var recordIndex = store.indexOf(selectedRecord);
var nextRecord = store.getAt(recordIndex + 1);
selModel.select(nextRecord);