Hybrid View
-
11 Apr 2012 7:30 AM #1
Answered: Extjs Tree Store auto sync with server
Answered: Extjs Tree Store auto sync with server
Hi,
how to use store to sync with server when using a Tree ?
I tried to use TreeStore but it does not have any appendChild oder addChild.
NodeInterface has a appendChild method but it does not sync with the server trough the store or proxy...
Any ideas ?
-
Best Answer Posted by vietits
Which version do you use? TreeStore.autoSync has effect only from Ext 4.1.
-
11 Apr 2012 3:13 PM #2
1. You add records into TreeStore through its nodes. The following example shows how to add a node into root node.
2. To sync TreeStore to with server, you use treestore.sync() or set its autoSync to true to automatically sync.Code:treestore.getRootNode().appendChild({text: 'node', leaf: true....});
-
12 Apr 2012 6:23 AM #3
It works actually very well.
I just have a problem because the autoSync does not work even though it's set to true...
I also tried destroy(), but it produces an error and I can't figure out which line produces it:var store = Ext.getStore('MyStore');
store.getNodeById(id).remove(); // No Ajax here
store.sync(); // Ajax..
TypeError: Cannot call method 'indexOf' of undefined
-
12 Apr 2012 6:39 AM #4
Below is my fix in removing a node.
Code:var store = Ext.getStore('MyStore'); // store.getNodeById(id).remove(); // No Ajax here var node = store.getNodeById(id); node.parentNode.removeChild(node); store.sync(); // Ajax..
-
12 Apr 2012 6:47 AM #5
I works, but it's not autoSync

I would like to have autoSync
-
12 Apr 2012 3:56 PM #6
Which version do you use? TreeStore.autoSync has effect only from Ext 4.1.


Reply With Quote