Nov 03, 2010, 1:46 PM
[CLOSED] When dynamically creating a TreePanel during page load, how do you hook up the "submitNodes" event?
I am creating a tree panel dynamically in the page load event of a page, then adding it to some container like a panel. However, I cannot figure out how to handle the "submitNodes" event as I get an error. The final solution will have the ability to add new nodes via drag and drop, but I need a way to be able to know when new nodes have been added. I thought the submitNodes would be a good way to do this - let me know if there is an alternative way to achieve this with the way I have it.
Here is my ASPX:
I guess if using
Any help very much appreciated!
Cheers.
Here is my ASPX:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DummyPage.aspx.cs" Inherits="Testing.DummyPage" %>
<!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 runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<ext:ResourceManager runat="server" ID="resMan" />
<ext:Panel runat="server" ID="PnlContainer" />
</div>
</form>
</body>
</html>
Here is my code behind:using System;
using Ext.Net;
namespace Testing
{
public partial class DummyPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
var tree = new TreePanel { ID = "testTree" };
tree.Title = "Test";
//and a root node so something is in there
var root = new TreeNode { AllowDrag = false, Text = "Form Name", Expanded = true };
tree.Root.Add(root);
//create a save button to perform a "submitNodes"
var saveButton = new Button
{
ID = "saveDef",
Icon = Icon.Disk,
Text = "Save Changes",
};
saveButton.Listeners.Click.Handler = "#{testTree}.submitNodes();";
//add the save button to the buttons of the treepanel
tree.ButtonAlign = Alignment.Left;
tree.Buttons.Add(saveButton);
//add the dynamically created treepanel to the container panel
PnlContainer.Items.Add(tree);
}
}
protected void SubmitNodes(object sender, SubmitEventArgs e)
{
X.Msg.Alert("Submit", "You have submitted " + e.RootNode.Children.Count + " nodes").Show();
}
}
}
The error I get is an HTTP 500 server error with:
System.Web.HttpException: The control with ID 'testTree' not found
saveButton.Listeners.Click.Handler = "#{testTree}.submitNodes();";
is just not going to work because it can't find the control, I need some way of getting the nodes from the client to the server. I have seen some other posts which use a "getJsonTree" javascipt method to get a JSON representation of the tree nodes and send that back to the server, which would work except I can't get a reference to the root node to be able to do that as I have the same problem that I cannot reference the treepanel on the client side when dynamically creating it like this.Any help very much appreciated!
Cheers.
Last edited by Daniil; Nov 04, 2010 at 10:23 AM.
Reason: [CLOSED]