Results 1 to 4 of 4

Thread: Ajax tab and reload content

  1. #1

    Default Ajax tab and reload content

    Hallo!

    I have a trouble with tabs. When I put more than one tab and I switch between them, I need to refresh each time I do it. For example, there are two tabs, named "one" and "two", both loaded from ajax.
    When I click the "one" tab, the content is dinamically loaded from the server. Then I click "two" and the program loads the its content from the server. Then I click "one" again, and my need is to ask again to the server to load content (that may be changet in the meantime).

    Thanks
    Alessio

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    Write a tabchange event handler for the tabpanel or an activate event handler for every tabitem that loads the body of the tabitem.

  3. #3

    Default

    Hi!
    Thank you for your answer. I fount the following solution:

    PHP Code:
                    {
                        
    region'center',
                        
    margins'5 0',
                        
    xtype'tabpanel',
                        
    activeTab0,
                        
    items: [
                            {
                                
    title"My grid",
                                
    layout"fit",
                                
    listeners: {
                                    
    activate: function(panel) {
                                        
    activatePanel1(panel);
                                    }
                                }
                            },
                            {
                                
    title"My tree",
                                
    listeners: {
                                    
    activate: function(panel) {
                                        
    activatePanel2(panel);
                                    }
                                }
                            }
                        ]
                    }, 
    with the function:

    PHP Code:
            function activatePanel2(panel) {
                var 
    tree = new Ext.tree.TreePanel({
                    
    useArrowstrue,
                    
    autoScrolltrue,
                    
    animatetrue,
                    
    enableDDtrue,
                    
    containerScrolltrue,
                    
    borderfalse,
                    
    dataUrl'ext.tree.php?action=get_tree',
                    
    root: {
                        
    nodeType'async',
                        
    text'[root]',
                        
    draggablefalse,
                        
    id'root'
                    
    }
                });
                
                
    panel.removeAll();
                
    panel.add(tree);
                
    panel.doLayout();
            } 
    That work for me.
    Is there a better solution in which I can put my code in the definition of the TabPanel and then fire something like "refresh" or "reload" in the listener and it repeats the same code again?

    Thanks
    Alessio

  4. #4
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    Why destroy the tree and create it again? Why not use the tree as tabitem directly (no need for the extra panel) and only reload the root node on tab activate?

Similar Threads

  1. How To Auto Reload Tab Panel Content?
    By ontangian in forum Ext 2.x: Help & Discussion
    Replies: 14
    Last Post: 19 Apr 2014, 9:22 PM
  2. Tab - Reload content
    By noah17 in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 27 Apr 2011, 6:04 PM
  3. refresh / reload - content of a tab in a panel
    By n00b in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 23 Jul 2010, 12:58 AM
  4. How to reload content of tab
    By praneeth528 in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 19 Apr 2008, 4:49 AM
  5. reload tab content
    By mcheung63 in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 14 Jan 2008, 6:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •