Results 1 to 7 of 7

Thread: Defer JsonWriter's automatic save calls?

  1. #1
    Sencha Premium Member mw-flow's Avatar
    Join Date
    Dec 2007
    Location
    Munich, Germany
    Posts
    113
    Vote Rating
    1
      0  

    Question Defer JsonWriter's automatic save calls?

    Hi all,

    i use a JsonStore that has a JsonWriter configured in order to write changes to the store back to the server. The remove and the insert method of the store fire the corresponding remove and insert event immediatly. Everytime they do this, however, the store's save method seems to be called, resulting in an immediate POST request to the server. In my case, I always need to save all of the store's records back to the server. So to decrease the number of POST requests to avoid network latency time, I'd like to defer the save calls for say 500ms after the last remove/insert event. How can I do this?

    Thanks a lot :-)

    mw-flow

  2. #2
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364
    Vote Rating
    86
      0  

    Default

    From my experience, writer won't dump all of teh store's records. your case is pretty unique. Most people CRUD on records, not on a store.

  3. #3
    Sencha Premium Member mw-flow's Avatar
    Join Date
    Dec 2007
    Location
    Munich, Germany
    Posts
    113
    Vote Rating
    1
      0  

    Default

    Hi Jay,

    thanks for your reply. And you're right, of course, my case is pretty unique. Do you think it's sensible in my case to just subclass the JsonStore, write the insert and remove method in a way that they don't fire the insert/remove event and call store.save() manually after the calls to insert/remove?

    <edit>Hmmm... I just noticed that Record's endEdit method again triggers the store to call its save method. So I would have to use a different Record class all over the place and, thus, I would probably have to use a different Store class that would be using that new Record class all over... right?</edit>

    <edit2>Hmmmmmm... why does my store's save method get called anyway? The 3.0 RC-1.1 documentation says for the batchSave config option "Defaults to false, which requires manually calling save to send all modifiedRecords to the server. Specify true for the store to automatically save records to the server when a record changes." I haven't set batchSave to anything, so save should not be called anyway after each insert/remove or call to endEdit of a record, right?</edit2>

    Best regards
    mw-flow

  4. #4
    Sencha Premium Member mw-flow's Avatar
    Join Date
    Dec 2007
    Location
    Munich, Germany
    Posts
    113
    Vote Rating
    1
      0  

    Default

    Bump - Thanks for having a look.

  5. #5
    Sencha Premium Member mw-flow's Avatar
    Join Date
    Dec 2007
    Location
    Munich, Germany
    Posts
    113
    Vote Rating
    1
      0  

    Question

    The batchSave issue still bugs me. The Documentation says for batchSave: "Defaults to false, which requires manually calling save to send all modifiedRecords to the server. Specify true for the store to automatically save records to the server when a record changes."

    However, my Store get saved after each change despite me not having set batchSave to true...

  6. #6
    Sencha Premium Member mw-flow's Avatar
    Join Date
    Dec 2007
    Location
    Munich, Germany
    Posts
    113
    Vote Rating
    1
      0  

    Default

    Quote Originally Posted by mw-flow View Post
    The batchSave issue still bugs me. The Documentation says for batchSave: "Defaults to false, which requires manually calling save to send all modifiedRecords to the server. Specify true for the store to automatically save records to the server when a record changes."

    However, my Store get saved after each change despite me not having set batchSave to true...
    No reply for 8 days now despite 164 thread views. Hmmm... to make answering easier:

    [ ] no-one needs batchSave = false
    [ ] the documentation is wrong
    [ ] it is a bug in 3.0 RC-1.1 beta
    [ ] my question was just plain silly and i should stick my head in the sand

    Check all that apply.

  7. #7
    Sencha User chesstrix's Avatar
    Join Date
    Apr 2008
    Posts
    117
    Vote Rating
    1
      0  

    Default

    I have the same need to dump all of the changed records in a store at one point. So your issue is certainly not unique.

    I read the docs as batch (not batchSave) true to send all recs as one transaction but only id autoSave is also set to false.

    I have only just begun to implement this but instantly found that if I modify one record and then force a store.save() that two identical transactions are fired off. It's as if the autoSave: false is doing nothing?

    Still investigating...

    Oops, my bad. It helps if you put the autoSave on the Store NOT the JsonWriter

Posting Permissions

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