[CLOSED] [1.0] Reload treepanel

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] [1.0] Reload treepanel

    hi, i created a treepanel that i populate with the database, the first time it shows ok, i copied the example from Refresh_Static_Tree
    to reload the tree, but every time i reload the tree it doesn't show it well, it removes the first node and the other ones, i debugged the nodes.ToJson and it seems to be all right.
    can you give me an example to do a sucessfully reload after load?

    thanks.
  2. #2

    RE: [CLOSED] [1.0] Reload treepanel

    Hi,

    Does example from Examples Explorer (Refresh_Static_Tree) work for you?
    Please provide your test sample which demonstrates the problem
  3. #3

    RE: [CLOSED] [1.0] Reload treepanel

    I'm assuming this has been solved, so marking as [CLOSED]. Please feel free to post more information if it becomes available.

    Geoffrey McGill
    Founder
  4. #4

    RE: [CLOSED] [1.0] Reload treepanel

    hi geoffrey, can you give me an example of TreePanel/Basic/Refresh_Static_Tree/ with multiple nodes with childs?
    because i can't get this working
    thanks
  5. #5

    RE: [CLOSED] [1.0] Reload treepanel

    Hi,

    Can you describe configuration of your tree? Refreshing depends from loader, type of nodes (Async or not)
  6. #6

    RE: [CLOSED] [1.0] Reload treepanel

    hi Vladimir, the loader is not sync.
    i need a static tree that loads the first time, and when i add a node, i need to refresh another treepanel with the sames nodes. i'm trying to do a page with parent-child module.
    Thanks

  7. #7

    RE: [CLOSED] [1.0] Reload treepanel

    Hi,

    It is better if you post own test sample because I am not sure what problem you have

    In any way, here a sample with refreshing static tree with subnodes
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack &amp;&amp; !X.IsAjaxRequest)
            {
                this.BuildTree(TreePanel1.Root);
            }
        }
    
        private Ext.Net.TreeNodeCollection BuildTree(Ext.Net.TreeNodeCollection nodes)
        {
            if (nodes == null)
            {
                nodes = new Ext.Net.TreeNodeCollection();
            }
            
            Ext.Net.TreeNode root = new Ext.Net.TreeNode();
            root.Text = "Root";
            nodes.Add(root);
    
            string prefix = DateTime.Now.Second + "_";
            for (int i = 0; i < 10; i++)
            {
                Ext.Net.TreeNode node = new Ext.Net.TreeNode();
                node.Text = prefix + i;
                root.Nodes.Add(node);
    
                for (int j = 0; j < 10; j++)
                {
                    Ext.Net.TreeNode subnode = new Ext.Net.TreeNode();
                    subnode.Text = node.Text + "_" + j;
                    node.Nodes.Add(subnode);
                }
            }
    
            return nodes;
        }
    
        [DirectMethod]
        public string RefreshMenu()
        {
            Ext.Net.TreeNodeCollection nodes = this.BuildTree(null);
    
            return nodes.ToJson();
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head2" runat="server">
        <title>SiteMap - Ext.NET Examples</title>
        <link href="../../../../resources/css/examples.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript">
            var refreshTree = function (tree) {            
                Ext.net.DirectMethods.RefreshMenu({
                    success : function (result) {
                        var nodes = eval(result);
                        if(nodes.length > 0){
                            tree.initChildren(nodes);
                        }
                        else{
                            tree.getRootNode().removeChildren();
                        }
                    }
                });
            }
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:TreePanel 
                ID="TreePanel1" 
                runat="server" 
                Icon="Anchor" 
                Title="Tree"
                AutoScroll="true" 
                Width="250" 
                Collapsed="False" 
                CollapseFirst="True" 
                HideParent="False"
                RootVisible="False" 
                BodyStyle="padding-left:10px">
                <Tools>            
                    <ext:Tool Type="Refresh" Qtip="Refresh" Handler="refreshTree(#{TreePanel1});" />
                </Tools>
             </ext:TreePanel>
        </form>
    </body>
    </html>
  8. #8

    RE: [CLOSED] [1.0] Reload treepanel

    thanks Vladimir, that samples worked great!!, now i have another problem, i'm using remote mode to do some stuffs in the database, but when i'm trying to get the new node index, i can't get it from the remotemoveeventsargs.
    here is the function that i'm using:
    what can i do to get that parameter? maybe an ExtraParams, but nothing that i tested worked.
    thanks in advance

        Protected Sub RemoteMove(ByVal sender As Object, ByVal e As RemoteMoveEventArgs)
            Dim intID As Integer = 0
            Try
                intID = e.NodeID.ToString.ToUpper.Replace("ID_", "")
                If intID <> 0 Then
    ' I need here to see what is the new index to put it in the DB
                    e.Accept = True
                Else
                    e.Accept = False
                End If
            Catch ex As Exception
                e.RefusalMessage = Err.Description
                e.Accept = False
            End Try
        End Sub
  9. #9

    RE: [CLOSED] [1.0] Reload treepanel

    juane66 (3/26/2010) thanks Vladimir, that samples worked great!!, now i have another problem, i'm using remote mode to do some stuffs in the database, but when i'm trying to get the new node index, i can't get it from the remotemoveeventsargs.
    here is the function that i'm using:
    what can i do to get that parameter? maybe an ExtraParams, but nothing that i tested worked.
    thanks in advance

        Protected Sub RemoteMove(ByVal sender As Object, ByVal e As RemoteMoveEventArgs)
            Dim intID As Integer = 0
            Try
                intID = e.NodeID.ToString.ToUpper.Replace("ID_", "")
                If intID <> 0 Then
    ' I need here to see what is the new index to put it in the DB
                    e.Accept = True
                Else
                    e.Accept = False
                End If
            Catch ex As Exception
                e.RefusalMessage = Err.Description
                e.Accept = False
            End Try
        End Sub
    any help please?

  10. #10

    RE: [CLOSED] [1.0] Reload treepanel

    Hi,

    Sorry for the late response.
    RemoteMoveEventArgs gives you the following properties which can help you to detect drop position:
    - TargetNodeID : target node id
    - Point : define drop point regarding target node (append, above, below)


    That information is enough to understand the drop position
    But if you still need index then use BeforeRemoteMove listener of the tree
    <BeforeRemoteMove Handler="params.index = e.point == 'append' ? target.childNodes.length : target.parentNode.indexOf(target);" />


    On server side
    e.ExtraParams["index"]
Page 1 of 2 12 LastLast

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. Reload TreePanel
    By Maia in forum 1.x Help
    Replies: 1
    Last Post: Jan 07, 2010, 4:39 AM
  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