PDA

View Full Version : Datastore - Insert works in reverse order



grubi
2 Nov 2009, 12:02 PM
Hi.

Is this a bug or by design?

If you pass an array of records to the insert method of a data store the records are present in reverse order at the datastore after the operation finished.

Regards.

2 Nov 2009, 12:19 PM
can you provide a working example of this in action? save us some time dude. we're helping lots of people.

Animal
2 Nov 2009, 12:42 PM
He's right.

The code is



insert : function(index, records){
records = [].concat(records);
for(var i = 0, len = records.length; i < len; i++){
this.data.insert(index, records[i]);
records[i].join(this);
}
this.fireEvent('add', this, records, index);
},



So each new one gets inserted at the insertion point, so they get reversed.

Should be



insert : function(index, records){
records = [].concat(records);
for(var i = 0, len = records.length; i < len; i++){
this.data.insert(index++, records[i]);
records[i].join(this);
}
this.fireEvent('add', this, records, index);
},

grubi
2 Nov 2009, 12:50 PM
can you provide a working example of this in action? save us some time dude. we're helping lots of people.

Sorry for not supplying an example. From the extjs sources I thought it was clear that it works the way I described.

Next time I will quote the ext source to make it clearer.

Regards.