[CLOSED] TreePanel Clear Root Nodes, Add More from AjaxMethod

  1. #1

    [CLOSED] TreePanel Clear Root Nodes, Add More from AjaxMethod



    Is it possible to clear out all nodes and add, insert, delete, modify nodes from an ajax method on a treepanel?

    How about records with a gridpanel for that matter?

    Is there a method call I could use or do I have to emit a bunch of javascript?

    Thanks!
  2. #2

    RE: [CLOSED] TreePanel Clear Root Nodes, Add More from AjaxMethod

    Is it possible to clear out all nodes and add, insert, delete, modify nodes from an ajax method on a treepanel?
    At the moment these Methods are not supported during an AjaxMethod/AjaxEvent call. This is a top priority for us and we will be adding the functionality during the v0.8 cycle.


    </p>
    Geoffrey McGill
    Founder
  3. #3

    RE: [CLOSED] TreePanel Clear Root Nodes, Add More from AjaxMethod



    We have to release before v0.8 comes out. Should I just emit some javascript like tree.getRootNode().clear() or whatever it should be?
  4. #4

    RE: [CLOSED] TreePanel Clear Root Nodes, Add More from AjaxMethod

    Hi David,

    Removing all the Nodes from a Parent was a bit more complicated that I had originally thought. The following script will remove all Children Nodes from a Parent Node.

    Example

    var root = TreePanel1.getRootNode();
    while (root.childNodes.length > 0) {
       root.removeChild(root.childNodes[0]);
    }
    We might be able to add a helper function to the TreeNode class that will wrap up this functionality in just .removeChildren();

    Hope this helps.

    Geoffrey McGill
    Founder
  5. #5

    RE: [CLOSED] TreePanel Clear Root Nodes, Add More from AjaxMethod

    A .RemoveChildren would be extremely helpful. So for the time being, if I want to refresh a node (not the root) of a tree, I literally have to loop through each child and remove?
  6. #6

    RE: [CLOSED] TreePanel Clear Root Nodes, Add More from AjaxMethod

    I've added the .removeChildren() function to the TreeNode class.

    Here's a simple sample demonstrating the use of .removeChildren().

    Example

    <ext:TreePanel ID="TreePanel1" runat="server" Width="300" Height="500">
        <Root>
            <ext:TreeNode Text="Item1" Expanded="true">
                <Nodes>
                    <ext:TreeNode Text="Item2" />
                    <ext:TreeNode NodeID="Node3" Text="Item3">
                        <Nodes>
                            <ext:TreeNode Text="Item3-1" />
                            <ext:TreeNode Text="Item3-2" />
                            <ext:TreeNode Text="Item3-3" />
                            <ext:TreeNode Text="Item3-4" />
                            <ext:TreeNode Text="Item3-5" />
                            <ext:TreeNode Text="Item3-6" />
                        </Nodes>
                    </ext:TreeNode>
                    <ext:TreeNode Text="Item4" />
                    <ext:TreeNode Text="Item5" />
                    <ext:TreeNode Text="Item6" />
                </Nodes>
            </ext:TreeNode>
        </Root>
        <Listeners>
            <Click Handler="node.removeChildren();" />
        </Listeners>
    </ext:TreePanel>
    Hope this helps.

    Geoffrey McGill
    Founder
  7. #7

    RE: [CLOSED] TreePanel Clear Root Nodes, Add More from AjaxMethod

    I hate to bring up such an old thread. But is there something like this in 1.0 for code behind? I'm trying to clear all the nodes in a tree before I rebind with different data than was previously in the treepanel.

    Thanks.
  8. #8

    RE: [CLOSED] TreePanel Clear Root Nodes, Add More from AjaxMethod

    Hi,

    TreePanel has many methods. To remmove chidren nodes for particular node please use RemoveChildren method
    TreePanel1.RemoveChildren(parentNodeId)
  9. #9
    what if i want to remove or hide the root itself ???

    and leave children.
    Last edited by elbanna23; Jun 25, 2014 at 12:50 PM.
  10. #10
    Quote Originally Posted by elbanna23 View Post
    what if i want to remove or hide the root itself ???

    and leave children.
    I guess this is a related thread, isn't?
    http://forums.ext.net/showthread.php...in-a-TreePanel

Similar Threads

  1. TreePanel without Root node
    By Dominik in forum 1.x Help
    Replies: 3
    Last Post: Jun 25, 2014, 7:07 PM
  2. TreePanel - load root with loader
    By pintun in forum 1.x Help
    Replies: 2
    Last Post: Apr 14, 2010, 8:19 PM
  3. Retrieve treepanel's root after reload
    By whitvanilla in forum 1.x Help
    Replies: 0
    Last Post: Jun 04, 2009, 9:28 AM
  4. How do I clear out a child nodes from a TreeNode?
    By dbassett74 in forum 1.x Help
    Replies: 3
    Last Post: May 26, 2009, 1:39 PM
  5. [CLOSED] TreePanel + AjaxMethod + AsyncNode + Root
    By state in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: May 08, 2009, 8:01 AM

Posting Permissions