Results 1 to 3 of 3

Thread: Store.getModifiedRecords

  1. #1
    Sencha Premium Member
    Join Date
    Mar 2007
    Posts
    65

    Default Store.getModifiedRecords

    Should the following code work? I'm creating a new record and inserting into a JSONStore. I can use FireBug and see the record dirty = true phantom = true. When I call .getModifiedRecords() I always get an empty array.

    Code:
    var r = new MyRecord({"fieldname":"This is a test"});				
    MyStore.addSorted(r);		
    MyStore.getModifiedRecords();

  2. #2
    Ext User
    Join Date
    Nov 2008
    Location
    Oakland, CA
    Posts
    155

    Default

    I'm having the a similar problem. I would like the record to be marked as modified when the insert happens and I can't figure out how to do this. Does anyone have any tips to make the insert or add of a record cause the record to be modified?

    I just found Record.markDirty() which causes the record to look dirty in the grid but it's still not being added to getModifiedRecords(). Why?

  3. #3

    Default

    Well this took some head scratching and poking in the source code. From what I could decipher, this.modified was not being created/filled for the added record but was if I edited/modified an existing record in the grid. Looking to see where and how this.modified came from I came across this comment

    "Store#add will call this automatically if a Writer is set"

    at the code for the createRecord function in the source for the store. createRecord looked to be the only thing that put something into this.modified using the line:

    "this.modified.push(rs[i]); // <-- add to modified"

    Hummmm, so I created a dummy writer and added it to the config for the store.

    Code:
    var dummyWriter = new Ext.data.JsonWriter();
    
    var myStore = new Ext.data.GroupingStore({
        ...
        writer: dummyWriter
    });
    and now my added records get marked as dirty in the grid along with any edited ones and both added and edited records get returned when calling getModifiedRecords() for the store.

Posting Permissions

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