View Full Version : [ExtJs 4.0.1] TreeStore with Rest Proxy and autoSync

10 Jun 2011, 2:59 AM

the autoSync feature isnt working for me

Ext.define('TEST.store.Groups', {
extend: 'Ext.data.TreeStore',
model: 'TEST.model.Group',
autoSync: true,
proxy: {
type: 'rest',
url: 'myRestBackend/',
reader: {
type: 'json',
root: 'data'
writer: {
type: 'json'
nodeParam: 'id',
root: {
name: 'Root',
draggable: false,
id: 'root'

if i drag and drop nodes on the tree no store.sync() is called ...

10 Jun 2011, 8:00 AM
Yes, I've tested it with tree example (http://dev.sencha.com/deploy/ext-4.0.2/examples/tree/reorder.html) and tt looks like "not implemented" then. autoSynced store will sync (save) record changes, additions and deletions but not (yet?) reordering.

Moving this thread to Bugs for devels to explain or fix.

8 Jul 2011, 4:02 PM

Ext.create('Ext.data.TreeStore', {
proxy: {
reader: 'json',
url: 'action/do'
listeners: {
move: function( node, oldParent, newParent, index, options ) {

14 Sep 2011, 11:04 PM
I hope some bugs already fixed in 3 months.
I have a couple problems to synchronize a TreeStore:

1) Reload store. > store.load(); and then store.sync() - store reloads successfully but has dirty first child and sends destroy action. (clearOnLoad=true/false not helps. Removing all nodes manually generates another problem).

2) Append new node. > node.append(newNode); store.sync(); - store sends create action. Upon successful response, new node is updated but store sends another request with update action to update parent node or siblings but never newNode.

My question is
What response a TreeStore is expecting to clear dirty flag or what is a right approach to handle CRUD in TreeStore?

I'm using Ext4 JSON Reader and Writer with Ajax Proxy and Model.

Thank you.

15 Sep 2011, 4:23 AM
Afaik, the response should be an array of the nodes you've updated or created....

15 Sep 2011, 5:55 AM
1) When store load records first time the Ext.data.NodeInterface.updateInfo(true) is called for each node/record and me.commit() is executed as well. Same happened when store records are reloaded. But store.getRemovedRecords().length = number of removed nodes and store.sync() sends destroy action; In both cases same response is received by store;

16 Sep 2011, 5:39 PM
If nodes ids are unique you may use this temp patch:

Ext.override(Ext.data.TreeStore, {
onNodeAdded: function(parent, node) {
for(var i=0; i < this.removed.length;i++){
if(node.id == this.removed[i].id){
Ext.Array.remove(this.removed, this.removed[i]);
this.callOverridden([parent, node]);

Make sure TreeStore.clearOnLoad = true (default)

16 Sep 2011, 10:43 PM
When node is created and store received successful response then node.dirty = true and it is a subject for update action. Temp patch below will help to set node.dirty = false

Ext.override(Ext.data.TreeStore, {
onCreateRecords: function(records, operation, success) {
this.callOverridden([records, operation, success]);
for (var i=0; i < records.length; i++)

10 Apr 2013, 7:26 AM
Was this problem ever fixed? The drag and drop still doesn't fire a sync in 4.1.1 or 4.2.0.

If I create a "move" event on the treestore, is there a way of call treestore.sync() and will the treestore know that a node has been dragged and dropped?

Or, it is possible to manually perform a proxy.Rest to get around this problem, if so, can you provide an example.

For reference, I'm using Architect 2.2.0 Build 908. So please based examples on this environment.