[CLOSED] TreePanel is not refresh in button click

  1. #1

    [CLOSED] TreePanel is not refresh in button click

    Hi,

    TreePanel is not show when I bind TreePanel in button click event.
    But when I call this in Page Load TreePanel is show.
    How to refresh TreePanle dynamically from code behind.

    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>    
    <script runat="server">   
        private Ext.Net.NodeCollection BuildTree(Ext.Net.NodeCollection nodes)
        {
            if (nodes == null)
            {
                nodes = new Ext.Net.NodeCollection();
            }
    
            Ext.Net.Node root = new Ext.Net.Node();
            root.Text = "Root";
            root.Expanded = true;
            nodes.Add(root);
            
            string prefix = DateTime.Now.Second + "_";
    
            for (int i = 0; i < 10; i++)
            {
                Ext.Net.Node node = new Ext.Net.Node();
                node.Text = prefix + i;
                node.Leaf = true;
                node.Expanded = true;
                root.Children.Add(node);
            }
    
            return nodes;
        }
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack && !X.IsAjaxRequest)
            {
                //this.BuildTree(TreePanel1.Root); // tree is show if bind in page load method
            }
        }
        protected void Button1_DirectClick(object sender, DirectEventArgs e)
        {
            this.BuildTree(TreePanel1.Root); // not showing if i bind tree panel in button click event
        }
    </script>    
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title></title> 
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />  
            <ext:Button ID="Button1" runat="server" Text="Load TreePanel" >
                <DirectEvents>
                    <Click OnEvent="Button1_DirectClick"></Click>
                </DirectEvents>
            </ext:Button>
            <ext:TreePanel 
                ID="TreePanel1" 
                runat="server" 
                Title="Tree" 
                Width="300"
                Height="450" 
                Border="false"
                >
            </ext:TreePanel>       
        </form>
    </body>
    </html>
    Last edited by Daniil; Dec 22, 2015 at 9:47 AM. Reason: [CLOSED]
  2. #2
    Hi @canusr1,

    Please see the example.
    https://examples2.ext.net/#/TreePane...h_Static_Tree/
  3. #3
    How to refresh the Tree from code-behind in direct event (no refresh button on client side!)
                this.ArticleTree.Root.Clear();
    
                var articleNode = new Node();
                articleNode.Text = "Root";
                this.LoadArticles(articleNode.Children);
                this.ArticleTree.Root.Add(articleNode);
    does not work.

    Is there any way to let the Tree reload the nodes from the store?
  4. #4
    You can try to call this at the end:
    this.ArticleTree.ReRender();
  5. #5
    Thanks! It is working now.

Similar Threads

  1. Replies: 6
    Last Post: May 15, 2013, 10:07 AM
  2. [CLOSED] When button click, open the menu of button
    By supera in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 22, 2012, 4:23 PM
  3. treepanel in CodeBehind on button click ?
    By caoit in forum 1.x Help
    Replies: 1
    Last Post: Apr 13, 2011, 1:03 PM
  4. Replies: 4
    Last Post: Nov 19, 2010, 1:39 PM
  5. Replies: 2
    Last Post: Jul 30, 2010, 12:37 AM

Posting Permissions