Oct 30, 2015, 4:49 PM
Ext.data.Store.insert not working properly
Tried the following code bellow to move Grid rows up and down but the record is always inserted at the original index despite the index that I pass via "insert(index, records)".
Any idea?
Thanks
Any idea?
Thanks
function moveRow(grid, up) { var ds = grid.getStore();
var record = grid.getSelectionModel().getSelected().items[0];
var rindex = ds.indexOf(record);
rindex += up ? -1 : 1;
//Only modify >= ds.getCount() instead of > ds.getCount()
if (rindex < 0 || rindex >= ds.getCount()) {
return;
}
ds.remove(record);
ds.insert(rindex, record);//Will insert but the row is always inserted at the same index
//grid.getSelectionModel().selectRecords([record]); <--Doesn't work, commented
}