PDA

View Full Version : remove all records, except the first



SpinoWeb
1 Apr 2011, 7:12 AM
I'd want to remove all records from my store except the first.
Trying this code:

var xyGrd = Ext.getCmp('xyGrid');
var xyStr = xyGrd.store;
for(var i = 1; i < xyStr.getCount(); i++){
var vi = xyStr.getAt(i);
xyStr.remove(vi);
}
I saw that some records remain in the store... It looks that the "for" skips some records.
There is any other method to do that?


Thank you!

fay
1 Apr 2011, 7:46 AM
You need to go about it backwards:



var xyGrd = Ext.getCmp('xyGrid');
var xyStr = xyGrd.store;

for(var i = xyStr.getCount() - 1; i > 0; i--){
xyStr.removeAt(i);
}