19 Mar 2012 7:18 AM #1
Updating store data after confirmation by server
in my Ext JS application, I have a store that synchronizes its data with a remote server via the proxy's "api" configuration. This all works fine. Now, when a record gets updated in the web app and subsequently is sent to the server, the server might change some of the data and send this revised update back to the browser. The same situation is present when a new record gets created, and the server completes the record's data with a database-generated id, the current timestamp or something else. This works fine, too.
However, this behaviour causes the view to be updated two times - once when the record is updated in the browser and another time when it is updated again with the data sent back by the server. In some cases, this is visible to the user. It also makes it extremely difficult to do something like letting a freshly created record slide into the view, because its HTML element gets updated again shortly after the beginning of the animation. And there may be cases where the server may decide that the requested operation is not allowed or possible at all, for example when deleting records.
My question is: Is there a proper way to wait with the final store update until the server has sent a response? The store would need some kind of "buffer" with unconfirmed changes, which are not visible in whatever views the store is connected to until the remote side has had its final word on the requested operation.
Has anyone dealt with a similar problem before?
19 Mar 2012 11:28 AM #2
- Join Date
- Mar 2007
- Gainesville, FL
- Vote Rating
Your issue doesn't sound like it is with the store but the grid seeing the new record and then gets updated with the new data.
Sencha Inc, Senior Software Engineer
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services email@example.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!
When posting code, please use BBCode's CODE tags.
19 Mar 2012 11:43 AM #3
Thanks for your reply! Okay, that's another possibility. In my special case, it's not a grid but a DataView I wrote.
By default, this gets updated automatically once the data in the store gets updated, so how can I prevent it from doing that?