Results 1 to 3 of 3

Thread: Possible Store loadData append bug?

  1. #1
    Sencha User
    Join Date
    Jun 2009
    Location
    Colorado
    Posts
    51

    Default Possible Store loadData append bug?

    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!

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    The API docs are a bit confusing. You can't use add:true to replace existing records. It doesn't update the internal MixedCollection correctly and it doesn't fire the correct events to update linked components.

  3. #3
    Sencha User
    Join Date
    Jun 2009
    Location
    Colorado
    Posts
    51

    Default

    Thanks for the reply Condor. That is quite confusing, considering the API docs specifically state that you can use add:true to replace existing records.

    The good news is that I did find this thread describing the same exact issue which seems to be fixed in SVN. Seems like I have some waiting to do.

Similar Threads

  1. Replies: 9
    Last Post: 10 Aug 2010, 9:00 AM
  2. store.loadData()
    By smit_al in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 26 May 2009, 10:57 PM
  3. Replies: 8
    Last Post: 11 Feb 2009, 6:53 PM
  4. Store and loadData()
    By Bucs in forum Ext 2.x: Help & Discussion
    Replies: 5
    Last Post: 15 Oct 2008, 6:56 AM
  5. Ext.data.Store.loadData() append new records in a strange way!
    By Surgeon in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 14 Aug 2008, 6:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •