View Full Version : [CLOSED] Change node parent instead of removing and re-adding?

May 28, 2013, 5:43 PM

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

May 28, 2013, 8:19 PM
I think that it's not possible.

May 28, 2013, 8:39 PM
In case of you need an example:

<!DOCTYPE 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.set('leaf', true);

var referenceNode = App.TreePanel1.store.getNodeById('_b');
source = referenceNode.appendChild(source);
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:TreeStore ID="TreeStore1" runat="server">
<ext:Node Expanded="true">
<ext:Node NodeID="_a" Text="Ext.Net" Expanded="true">
<ext:Node NodeID="_aa" Text="Ext" Leaf="true" />
<ext:Node NodeID="_b" Text="core" Expanded="true">
<ext:Node NodeID="_bb" Text="Sencha" Leaf="true" />
<ext:Viewport ID="Viewport1" runat="server" Margins="0 0 10 0">
<ext:VBoxLayoutConfig Align="Center" Pack="Center" />
<ext:Button ID="Button1" Text="Move" runat="server">
<Click Handler="move();" />
<ext:TreePanel ID="TreePanel1" runat="server" Title="TreePanel" Width="300" Height="200"
Margin="10" RootVisible="false" Lines="false" UseArrows="false" StoreID="TreeStore1" />

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 });

return new StoreResult { Data = nodes.ToJson() };

May 29, 2013, 3:46 AM

Thank you Raphael for your sample!

Please, @extnetuser try Raphael's example? Does it work for you?

May 29, 2013, 6:01 AM

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?

May 29, 2013, 12:44 PM
Thank you Raphael for your sample!

You're welcome.

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