1. #1
    Ext User
    Join Date
    Aug 2007
    Posts
    33
    Vote Rating
    0
    magunes117 is on a distinguished road

      0  

    Question reloading a tree in parent of an iframe - from the iframe

    reloading a tree in parent of an iframe - from the iframe


    Hi,

    I am writing a sample application, and I have a treepanel on the left and the tree is loaded from dynamic json data (from database). On the right side of the page I have a tabpanel and inside an iframe which loads a different page everytime I click on a tree node from the left side.

    Now, one of my tree nodes opens a page with an ext form inside it and I use that form to create a row in the database table, which I got the tree nodes from. So, what I need is to see that new node inside the tree without refreshing the whole page. So I am trying something like:

    Code:
    parent.Ext.ComponentMgr.get('tree').render();
    to navigate to the parent of the iframe and then reload the tree somehow. But of course it is not working and I need you guys help.

    Thank you in advance, regards.

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,017
    Vote Rating
    650
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Well of course it's "not working", that's why you're posting here. The question is, what happens when it's not working. Do you get an error? Does nothing happen?

    If the tree already exists, you shouldn't be rendering it again.

  3. #3
    Ext User
    Join Date
    Aug 2007
    Posts
    33
    Vote Rating
    0
    magunes117 is on a distinguished road

      0  

    Default


    All right, sorry.

    Here is what firebug gives me:

    parent.Ext.ComponentMgr.get("tree") has no properties

    and here is the code for tree:

    Code:
    // generate tree
    var TreeTest = function(){
    
    	var root, tree;
    
    	return {
    		init : function(){
    			// ext tree
    			tree = new Ext.tree.TreePanel(panel2.body, {
    				animate: true,
    				loader: new Ext.tree.TreeLoader(),
    				enableDD: false,
    				containerScroll: true,
    				dropConfig: {appendOnly: true}
    			});
    
    			// set the root node
    			root = new Ext.tree.TreeNode({
    				text: 'Templates',
    				draggable: false, // disable root node dragging
    				id: 'Templates'
    			});
    			
    			tree.setRootNode(root);
    			
    			TemplateService.rpc.getDataView(query/*something like select * from treetable*/, function(r){
    				var json = Ext.decode(r).result; // result is like [{"text" : "CPU Info", "id" : "6", "leaf" : true, "cls" : "file"}]
    				for(var i = 0, len = json.length; i < len; i++) {
    					root.appendChild(tree.getLoader().createNode(json[i]));
    				}
    			}).call(ext_channel);
    			
    			tree.render();
    			
    			root.expand(false, /*no anim*/ false);
    		}		
    	};
    }();
    
    TreeTest.init();

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,017
    Vote Rating
    650
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    It's because you never give the tree an id, do this:

    Code:
    // generate tree
    var TreeTest = function(){
    
    	var root, tree;
    
    	return {
                    getTree: function() { return tree; },
    		init : function(){
    			// ext tree
    			tree = new Ext.tree.TreePanel(panel2.body, {
    				animate: true,
    				loader: new Ext.tree.TreeLoader(),
    				enableDD: false,
    				containerScroll: true,
    				dropConfig: {appendOnly: true}
    			});
    
    			// set the root node
    			root = new Ext.tree.TreeNode({
    				text: 'Templates',
    				draggable: false, // disable root node dragging
    				id: 'Templates'
    			});
    			
    			tree.setRootNode(root);
    			
    			TemplateService.rpc.getDataView(query/*something like select * from treetable*/, function(r){
    				var json = Ext.decode(r).result; // result is like [{"text" : "CPU Info", "id" : "6", "leaf" : true, "cls" : "file"}]
    				for(var i = 0, len = json.length; i < len; i++) {
    					root.appendChild(tree.getLoader().createNode(json[i]));
    				}
    			}).call(ext_channel);
    			
    			tree.render();
    			
    			root.expand(false, /*no anim*/ false);
    		}		
    	};
    }();
    
    TreeTest.init();
    
    
    window.parent.TreeTest.getTree().whatever();

  5. #5
    Ext User
    Join Date
    Aug 2007
    Posts
    33
    Vote Rating
    0
    magunes117 is on a distinguished road

      0  

    Default


    After adding the function I tried:

    Code:
    window.parent.TreeTest.getTree().render();
    Firebug gives the following error:

    window.parent.TreeTest has no properties

  6. #6
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,017
    Vote Rating
    650
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Then something is whacked out with the way you have your iframe set up. Post an example online.

  7. #7
    Ext User
    Join Date
    Aug 2007
    Posts
    33
    Vote Rating
    0
    magunes117 is on a distinguished road

      0  

    Default


    I am unable to post an online exampla now, but I am trying to reache other element inside the parent and the following works:

    I can get the location of parent
    Code:
    alert(window.parent.location);
    and I can change the source of the iframe (the one i am calling the fuctions from)
    Code:
    parent.Ext.get('workspace').dom.src = 'gridx.html';
    But I can not reload the tree.

  8. #8
    Sencha Premium Member
    Join Date
    May 2007
    Location
    USA
    Posts
    73
    Vote Rating
    0
    notjoshing is on a distinguished road

      0  

    Default


    Have you tried "window.parent.document.TreeTest.getTree().render();"?

    Josh

  9. #9
    Ext User
    Join Date
    Aug 2007
    Posts
    33
    Vote Rating
    0
    magunes117 is on a distinguished road

      0  

    Default


    Quote Originally Posted by notjoshing View Post
    Have you tried "window.parent.document.TreeTest.getTree().render();"?

    Josh
    Hi Josh,

    I have tried and got the same error.

    Thanks.

  10. #10
    Sencha Premium Member
    Join Date
    May 2007
    Location
    USA
    Posts
    73
    Vote Rating
    0
    notjoshing is on a distinguished road

      0  

    Default


    It's clearly some sort of referencing error. I remember having a similar issue a few years back, and the solution ended up being pretty simple, but it took some research and playing around. I think I'd break it down to simple HTML, and play around with the syntax until I got it. I'd try referencing the opener as well as the parent, try running directly off the window, etc.

    Good luck,

    Josh

Thread Participants: 2