PDA

View Full Version : TreePanel - RemoteMove not work with dynamically created control



jaysoncampa
12 May 2011, 2:47 AM
RemoteMove to fire the event on a node of a TreePanel the following error occurs:

"The control with ID 'treeReport' not found"

Basically I created a TabPanel dynamically with a button that creates dynamically by clicking a tab which is another type TreePanel and this tree has an event RemoteMove that moving a node tree is triggered the event.

I created a basic example to reproduce the problem:



<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">

protected override void OnInit(EventArgs e)
{
TabPanel tabMaster = new TabPanel
{
ID = "tabMaster",
Width = 400,
Height = 200
};
this.Form.Controls.Add(tabMaster);

Ext.Net.Panel pnlStart = new Ext.Net.Panel
{
ID = "pnlStart",
Title = "Start"
};
tabMaster.Items.Add(pnlStart);

Ext.Net.Button btnCreate = new Ext.Net.Button
{
ID = "btnCreate",
Text = "Create"
};
btnCreate.DirectClick += btnCreate_DirectClick;
pnlStart.Items.Add(btnCreate);
}

protected void btnCreate_DirectClick(object sender, DirectEventArgs e)
{
TreePanel treeReport = new TreePanel
{
ID = "treeReport",
Title = "Reports",
EnableDD = true,
Mode = TreePanelMode.Remote
};

Ext.Net.TreeNode nodeRoot = new Ext.Net.TreeNode
{
NodeID = "nodeRoot",
Text = "Root"
};
treeReport.Root.Add(nodeRoot);

Ext.Net.TreeNode node1 = new Ext.Net.TreeNode
{
NodeID = "node1",
Text = "Node 1"
};
nodeRoot.Nodes.Add(node1);

Ext.Net.TreeNode node2 = new Ext.Net.TreeNode
{
NodeID = "node2",
Text = "Node 2"
};
nodeRoot.Nodes.Add(node2);

treeReport.RemoteMove += treeRelatorio_RemoteMove;
treeReport.Render("tabMaster", RenderMode.AddTo);

var tab = X.GetCmp<TabPanel>("tabMaster");
tab.SetActiveTab("treeReport");
}

protected void treeRelatorio_RemoteMove(object sender, RemoteMoveEventArgs e)
{
if (e.NodeID.Equals("node1") && e.TargetNodeID.Equals("node2"))
e.Accept = true;
else
e.Accept = false;
}
</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>
<title></title>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
</form>
</body>
</html>


Can you help me please?

Thanks.