View Full Version : Saving tree grid changes to the server side

lee el
4 Mar 2013, 8:53 AM

I have a tree grid, for example:

-School A
+Teacher A
+Teacher B
-Teacher C
-Student A
-Student B
+school B

my tree has a treeStore with direct proxy

var store = Ext.create('Ext.data.TreeStore', { model : 'App.model.SchoolModel',
proxy: {
type: 'direct',
api: {
read: Server.getSchools,
update: Server.updateSchools,
autoLoad : false

user can update values on the tree and can add records to the tree,
what I see when dealing with direct API is that each action the user is making when I do store.sync()
for each action a different method is called on the server side (as it is defined in the proxy API).
My question is how can I do it in one call to a server method, for example user add new entity + update another entity + delete some other entity and in my server method I will get all the data and act upon this data (the entities will be marked for the appropriate action).
can this be achieved with direct API or should I use Ajax call to some URL on the server?


lee el
5 Mar 2013, 5:51 AM
OK, what I understand is that store.sync() is not running in one transaction which means that if I have these changes on my tree:
1. add new items
2. remove existing items
3. update existing items

and I am doing store.sync() there will be 3 posts to the server one for each action, and some actions can succeed and some can fail to commit changes to the server so the situation is not good! (some of the data commited and some not)

the only thing I found that can help a little but does not fix the problem is the batchOrder:'destroy,create,update',
of the direct proxy which let you decide which action to make first during the sync

any help regarding transaction with sync will help ...