Hybrid View

  1. #1
    Sencha User
    Join Date
    Jul 2010
    Posts
    33
    Vote Rating
    0
    Answers
    1
    charles.bourasseau is on a distinguished road

      0  

    Default 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 ?

  2. Which version do you use? TreeStore.autoSync has effect only from Ext 4.1.

  3. #2
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Vote Rating
    115
    Answers
    346
    vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold

      0  

    Default


    1. You add records into TreeStore through its nodes. The following example shows how to add a node into root node.
    Code:
    treestore.getRootNode().appendChild({text: 'node', leaf: true....});
    2. To sync TreeStore to with server, you use treestore.sync() or set its autoSync to true to automatically sync.

  4. #3
    Sencha User
    Join Date
    Jul 2010
    Posts
    33
    Vote Rating
    0
    Answers
    1
    charles.bourasseau is on a distinguished road

      0  

    Default


    It works actually very well.

    I just have a problem because the autoSync does not work even though it's set to true...

    var store = Ext.getStore('MyStore');
    store.getNodeById(id).remove(); // No Ajax here
    store.sync(); // Ajax..
    I also tried destroy(), but it produces an error and I can't figure out which line produces it:

    TypeError: Cannot call method 'indexOf' of undefined

  5. #4
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Vote Rating
    115
    Answers
    346
    vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold

      0  

    Default


    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..

  6. #5
    Sencha User
    Join Date
    Jul 2010
    Posts
    33
    Vote Rating
    0
    Answers
    1
    charles.bourasseau is on a distinguished road

      0  

    Default


    I works, but it's not autoSync

    I would like to have autoSync

  7. #6
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Vote Rating
    115
    Answers
    346
    vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold

      0  

    Default


    Which version do you use? TreeStore.autoSync has effect only from Ext 4.1.

Thread Participants: 1

Tags for this Thread