Reload TreePanel

  1. #1

    Reload TreePanel

    Hi,
    I created a dynamically treepanel and the first time it appears. However, after removing the children I perform the function to create treepanel again, but it does not appear. What function do I need to run treepanel show again?

    Aspx
      function removeTree() {
                var root = TreePanel1.getRootNode();
                while (root.childNodes.length > 0) {
                    root.removeChild(root.childNodes[0]);
                }
            }
       
      <ext:ToolbarButton ID="btnRefreshTree" runat="server" Icon="Cross" Hidden="true"> 
                                     <Listeners>
                                        <Click fn="removeTree" />
                                    </Listeners>
                                    <AjaxEvents>
                                        <Click OnEvent="RefreshTree"/>                                      
                                    </AjaxEvents>
                                </ext:ToolbarButton>
    Code C#
     public void RefreshTree(object sender, AjaxEventArgs e)
            {
                MontarTreeView();
            }
    protected void MontarTreeView()
            {            
                Coolite.Ext.Web.TreePanel tree = this.TreePanel1;           
                Coolite.Ext.Web.TreeNode root = new Coolite.Ext.Web.TreeNode();
                tree.Root.Clear();
                root.Text = "Itens Menu Sistema - " + sistema;
                root.NodeID = "-1";            
                root.Expanded = true;            
                tree.Root.Add(root);    
                MenuPrincipal[] menuPai = MenuPrincipalController.RetornarMenuPai(0,sistema);
                foreach (MenuPrincipal mp in menuPai)
                {
                    Coolite.Ext.Web.TreeNode nodePai = new Coolite.Ext.Web.TreeNode();                
                    nodePai.NodeID = mp.mnuId.ToString();
                    nodePai.Text = mp.mnuDescricao;
                    nodePai.Icon = ImagemIcone(mp.mnuIcone);                
                    root.Nodes.Add(nodePai);
                    MenuPrincipal[] menuFilho = MenuPrincipalController.RetornarMenuFilho(mp.mnuId);
                    foreach (MenuPrincipal mf in menuFilho)
                    {
                        Coolite.Ext.Web.TreeNode nodeFilho = new Coolite.Ext.Web.TreeNode();
                        nodeFilho.NodeID = mf.mnuId.ToString();
                        nodeFilho.Text = mf.mnuDescricao;
                        nodeFilho.Icon = ImagemIcone(mf.mnuIcone);                    
                        nodePai.Nodes.Add(nodeFilho);                    
                    }
                }
                
            }
    Maia
    Coolite 0.8.1
  2. #2

    RE: Reload TreePanel

    Hi,

    0.8.x doesn't support creating controls during AjaxEvent. Use the following example to refresh tree
    http://examples1.ext.net/#/TreePanel...h_Static_Tree/
    Vladimir Shcheglov
    Sr. Developer

Similar Threads

  1. reload store (grid) from treepanel
    By simbal in forum 1.x Help
    Replies: 1
    Last Post: Apr 28, 2012, 9:57 AM
  2. [CLOSED] Reload treepanel dynamically
    By mirwais in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jan 27, 2012, 3:00 PM
  3. TreePanel.Reload
    By ankit in forum 1.x Help
    Replies: 0
    Last Post: Jun 11, 2010, 7:05 AM
  4. [CLOSED] [1.0] Reload treepanel
    By juane66 in forum 1.x Legacy Premium Help
    Replies: 10
    Last Post: Mar 29, 2010, 6:22 PM
  5. Retrieve treepanel's root after reload
    By whitvanilla in forum 1.x Help
    Replies: 0
    Last Post: Jun 04, 2009, 9:28 AM

Posting Permissions