[CLOSED] Change node parent instead of removing and re-adding?

  1. #1

    [CLOSED] Change node parent instead of removing and re-adding?

    Hi,

    I have a TreePanel Leaf that I want to move from one parent Node to another.
    Is this possible without removing and readding it?

    Thank you
    Last edited by Daniil; Jun 04, 2013 at 5:07 AM. Reason: [CLOSED]
  2. #2
    I think that it's not possible.
    Last edited by RCN; May 28, 2013 at 7:37 PM.
  3. #3
    In case of you need an example:

    <!DOCTYPE html>
    <html>
    <head id="Head1" runat="server">
        <script type="text/javascript">
            var move = function () {
                var source = App.TreePanel1.store.getNodeById('_aa');
    
                var sourceParent = source.parentNode;
                sourceParent.removeChild(true);
                sourceParent.set('leaf', true);
    
                var referenceNode = App.TreePanel1.store.getNodeById('_b');
                source = referenceNode.appendChild(source);
            }
        </script>
    </head>
    <body>
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:TreeStore ID="TreeStore1" runat="server">
            <Root>
                <ext:Node Expanded="true">
                    <Children>
                        <ext:Node NodeID="_a" Text="Ext.Net" Expanded="true">
                            <Children>
                                <ext:Node NodeID="_aa" Text="Ext" Leaf="true" />
                            </Children>
                        </ext:Node>
                        <ext:Node NodeID="_b" Text="core" Expanded="true">
                            <Children>
                                <ext:Node NodeID="_bb" Text="Sencha" Leaf="true" />
                            </Children>
                        </ext:Node>
                    </Children>
                </ext:Node>
            </Root>
        </ext:TreeStore>
        <ext:Viewport ID="Viewport1" runat="server" Margins="0 0 10 0">
            <LayoutConfig>
                <ext:VBoxLayoutConfig Align="Center" Pack="Center" />
            </LayoutConfig>
            <Items>
                <ext:Button ID="Button1" Text="Move" runat="server">
                    <Listeners>
                        <Click Handler="move();" />
                    </Listeners>
                </ext:Button>
                <ext:TreePanel ID="TreePanel1" runat="server" Title="TreePanel" Width="300" Height="200"
                    Margin="10" RootVisible="false" Lines="false" UseArrows="false" StoreID="TreeStore1" />
            </Items>
        </ext:Viewport>
    </body>
    </html>
    namespace SandBox.Controllers
    {
        public class ExampleController : System.Web.Mvc.Controller
        {
            public ActionResult Index()
            {
                return View();
            }
    
            public StoreResult LoadTreeFakeChildren()
            {
                NodeCollection nodes = new NodeCollection(false);
    
                for (int index = 1; index < 6; index++)
                {
                    Node no = new Node();
                    no.NodeID = index.ToString() + DateTime.Now.Second;
                    no.CustomAttributes.Add(new ConfigItem { Name = "Task", Value = no.NodeID, Mode = ParameterMode.Value });
                    no.CustomAttributes.Add(new ConfigItem { Name = "Column1", Value = Guid.NewGuid().ToString(), Mode = ParameterMode.Value });
                    nodes.Add(no);
                }
    
                return new StoreResult { Data = nodes.ToJson() };
            }
        }
    }
  4. #4
    Hello!

    Thank you Raphael for your sample!

    Please, @extnetuser try Raphael's example? Does it work for you?
  5. #5
    Hi,

    Well, changing a node's parent supposes removing from an old parent and adding to a new one. So, I agree with Raphael that it is not possible to change a node's parent without those operations.

    Please clarify why is it going to be a problem?
  6. #6
    Quote Originally Posted by Baidaly View Post
    Thank you Raphael for your sample!
    You're welcome.


    @ExtNetUser, let us know if you need further assistance.

Similar Threads

  1. Replies: 16
    Last Post: Jul 19, 2011, 3:53 AM
  2. Replies: 1
    Last Post: Nov 24, 2010, 3:04 PM
  3. [CLOSED] Removing and Re-adding ResourceManager
    By randy85253 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 08, 2010, 11:32 AM
  4. Replies: 2
    Last Post: May 02, 2010, 4:33 PM
  5. [CLOSED] Grid adding removing columns in codebehind
    By methode in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Feb 24, 2009, 2:51 AM

Tags for this Thread

Posting Permissions