From my understanding, setting the second argument (append) of store.loadData to true will add records to the store instead of replacing the entire data set. However, the definition notates:
"Note: that Records in a Store are keyed by their id, so added Records with ids which are already present in the Store will replace existing Records."
I am attempting to load one record through this method which already exists in the store, with a desired result of updating that record with the new information passed. Instead, I am getting a few errors.
It seems that the record is correctly updated, but the number of records in the store is not properly updated - which causes the refresh of that row to fail.
It seems that in the store's loadRecords method the stores totalLength is updated regardless of whether or not the new record is truly added to the store, or just replacing an already existing record:
Code:
if(!options || options.add !== true){
if(this.pruneModifiedRecords){
this.modified = [];
}
for(var i = 0, len = r.length; i < len; i++){
r[i].join(this);
}
if(this.snapshot){
this.data = this.snapshot;
delete this.snapshot;
}
this.clearData();
this.data.addAll(r);
this.totalLength = t;
this.applySort();
this.fireEvent('datachanged', this);
}else{
this.totalLength = Math.max(t, this.data.length+r.length);
this.add(r);
}
Am I using this functionality incorrectly?
Has someone else managed to use load or loadData to replace an existing record?
Is this truly a bug?
Thanks for any responses!