1. #1
    Ext User janixams's Avatar
    Join Date
    Aug 2007
    Posts
    80
    Vote Rating
    0
    janixams is on a distinguished road

      0  

    Question Reload tree panel

    Reload tree panel


    Hello:
    I have a tree panel that loads data from the server and I have a form too. With this form the user can to change data on the server and i need to reload the treepanel when the user submit the form, wich is in a php archive.

    This is the code for the tree panel:
    PHP Code:
    var myTree = new Tree.TreePanel('tree-div', {
            
    loader: new Tree.TreeLoader({dataUrl:'./PHP/tree_generator.php'}),
            
    containerScrolltrue,
            
    id:'arbol',
            
    animate:true,
            
    enableDrag:true,
            
    dropConfig: {appendOnly:true},
            
    rootVisible:true
        
    });

        var 
    root = new Tree.AsyncTreeNode({
            
    text'Facultad 5',
            
    id:'facultad',
            
    draggable:false
        
    });
        
        
    myTree.setRootNode(root);
        
    myTree.render();
        
    myTree.expandAll(); 
    And this is the code associated to the save form button:
    [php]form.addButton("Guardar", function(){
    form.submit({
    params: {action:'submit'},
    waitTitle:'Espere por favor',
    waitMsg: 'Enviando los datos...',
    success: function(form, action){
    Ext.Msg.show({
    title:'Confirmaci

  2. #2
    Ext User janixams's Avatar
    Join Date
    Aug 2007
    Posts
    80
    Vote Rating
    0
    janixams is on a distinguished road

      0  

    Red face A variant

    A variant


    Hello again, my english is so bat, sorry for this.
    I have a possible solution here to the previous problem, but doesn't work totally fine.
    So, I have a toolbar and in a button click event, I call this function:
    PHP Code:
    function refrescar_datos_pp(){
        
    myTree.getLoader().load(myTree.root);
        
    myTree.root.render();
        
    myTree.expandAll();
    }
    function 
    expandAll(){
            
    setTimeout(function(){
                
    Rroot.eachChild(function(n){
                   
    n.expand(falsefalse);
                });
            }, 
    10);
    }; 
    So, the data is loaded perfectly but the child icons never appear and a folder icon shows in it's stead. I need to know, that it's wrong? I finaly load refresh the nodes and now they doesn't show the correct icon.
    Any help is welcome.
    Thanks in advance.

  3. #3
    Sencha User
    Join Date
    Nov 2007
    Posts
    243
    Vote Rating
    0
    JamesC is on a distinguished road

      0  

    Default


    Try setting leaf: false, expanded: true for all your nodes (then they should all render expanded)

  4. #4
    Ext User janixams's Avatar
    Join Date
    Aug 2007
    Posts
    80
    Vote Rating
    0
    janixams is on a distinguished road

      0  

    Thumbs up


    Thank you so much JamesC. It's work perfectly now.
    You are my savior.
    Thank you again.

  5. #5
    Sencha User
    Join Date
    Jul 2011
    Posts
    2
    Vote Rating
    0
    crashman is on a distinguished road

      0  

    Default


    Please! Tell me! How to reload tree panel in ExtJS 4? I have a form, when I submit form I wanna refresh my tree. Help please!

  6. #6
    Ext JS Premium Member
    Join Date
    Mar 2011
    Posts
    178
    Vote Rating
    0
    astrocybernaute is on a distinguished road

      0  

    Default


    did u find out how to do this?

  7. #7
    Sencha User
    Join Date
    Jul 2011
    Posts
    2
    Vote Rating
    0
    crashman is on a distinguished road

      0  

    Default


    Variant №1 - from view or Viewport(doesn't matter)


    tr.getView().getTreeStore().setRootNode(tr.getView().getTreeStore().getRootNode().getChildAt());
    tr.getView().refresh();


    tr - it's your view with TreePanel


    Variant №2 - from Controller


    reloadTree:function(){

    Ext.getStore('Comments').setRootNode(Ext.getStore('Comments').getRootNode().getChildAt());


    or


    this.getCommentsStore().setRootNode(getCommentsStore().getRootNode().getChildAt());


    this.getCommentsStore().load();
    }
    The main point is that you should reload root node.
    Please let me know if it works

  8. #8
    Ext JS Premium Member
    Join Date
    Mar 2011
    Posts
    178
    Vote Rating
    0
    astrocybernaute is on a distinguished road

      0  

    Default


    thank you soo much
    i didnt expect an answer and definitely not so soon
    thank you


    i tried ur code, it does reload the tree but it gives me an empty tree (im not using mvc)
    this is what i used

    myStore.setRootNode(myStore.getRootNode().getChildAt());

    myStore is the name of my store, i can access it directly

    i need to fill it but i dont know how!

    this is the definition of my store

    Code:
    window.myStore = Ext.create('Ext.data.TreeStore', {
    
        root: Ext.decode(obj.TreeToJson())
    
    
    });