PDA

View Full Version : Move Grid's rows up and down using button



Sohil.Patel
1 Oct 2013, 4:55 PM
Hi, I was going through ext js support forum and found below solution for moving grid's rows up and down but it seems to be working in Ext2.x but not with Ext 4.x. It seems that there is no method as getSelected() in new version of Ext js. Can someone please let me know how to get below code working?

getSelected() Method is not present any more



I am getting error saying getSelected() method is not present. What changes to be done in this code to move grid's row up and down working?

var record = grid.getSelectionModel().getSelected();
if (!record) {
return;
}
var index = grid.getStore().indexOf(record);
if (direction < 0) {
index--;
if (index < 0) {
return;
}
} else {
index++;
if (index >= grid.getStore().getCount()) {
return;
}
}
grid.getStore().remove(record);
grid.getStore().insert(index, record);
grid.getSelectionModel().selectRow(index, true);

ettavolt
1 Oct 2013, 10:39 PM
Try getSelection()[0].
But I must warn you, that this code can't be extended for case with multiple selections.