Oct 12, 2011, 4:01 AM
-
-
Oct 12, 2011, 7:34 AMI see you save selection there.
But I can't see where you restore that. -
Oct 12, 2011, 8:08 AMSorry,
in Page_Load.if (!X.IsAjaxRequest) { TreePanel1.CallNode("select", Session["EqpId"].ToString()); }
But It dosn't work.
The question is how to do this?Last edited by ginsar; Oct 12, 2011 at 8:12 AM. -
Oct 12, 2011, 8:54 AMWell, you could select a node when that node is loaded. I mean within a server side loader method.
As well, you can use Append listener.
Example
<%@ Page Language="C#" %> <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { if (!X.IsAjaxRequest) { object o = this.Session["selection"]; if (o != null) { string id = o.ToString(), handler = String.Format("onAppend(this, node, '{0}');", id); if (id == this.TreePanel1.Root[0].NodeID) { this.TreePanel1.CallNode("select", id); } else { this.TreePanel1.Listeners.Append.Handler = handler; this.TreePanel1.Listeners.Append.Delay = 100; } } } } protected void NodeLoad(object sender, NodeLoadEventArgs e) { if (!string.IsNullOrEmpty(e.NodeID)) { for (int i = 1; i < 6; i++) { AsyncTreeNode asyncNode = new AsyncTreeNode(); asyncNode.Text = e.NodeID + i; asyncNode.NodeID = e.NodeID + i; e.Nodes.Add(asyncNode); } for (int i = 6; i < 11; i++) { Ext.Net.TreeNode treeNode = new Ext.Net.TreeNode(); treeNode.Text = e.NodeID + i; treeNode.NodeID = e.NodeID + i; treeNode.Leaf = true; e.Nodes.Add(treeNode); } } } [DirectMethod] public void SaveSelection(string id) { this.Session["selection"] = id; } </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 runat="server"> <title>Ext.NET Example</title> <script type="text/javascript"> var onAppend = function (tree, node, nodeIdToSelect) { if (!tree.restoreSelectionLock) { if (node.id === nodeIdToSelect) { tree.getSelectionModel().select(node); tree.restoreSelectionLock = true; } } }; </script> </head> <body> <form runat="server"> <ext:ResourceManager runat="server" /> <ext:TreePanel ID="TreePanel1" runat="server" Title="Tree" AutoHeight="true" Border="false"> <Loader> <ext:PageTreeLoader OnNodeLoad="NodeLoad" /> </Loader> <Root> <ext:AsyncTreeNode NodeID="0" Text="Root" /> </Root> <SelectionModel> <ext:DefaultSelectionModel runat="server" > <Listeners> <SelectionChange Handler="Ext.net.DirectMethods.SaveSelection(node.id);" /> </Listeners> </ext:DefaultSelectionModel> </SelectionModel> </ext:TreePanel> </form> </body> </html>
-
Oct 12, 2011, 9:14 AMI tested your example.
I select a node and push F5.
After page reload I see only root node, but I'd like to see a tree and selected node. -
Oct 12, 2011, 9:17 AMThen you need to load that node.
-
Oct 12, 2011, 9:26 AMwhat do you mean?
I have to load all node before select saved node or I have to load only saved node? -
Oct 12, 2011, 9:59 AMI think all nodes, at least all parents of a selected node.
-
Oct 12, 2011, 10:36 AMAnd how can I do this?
Now the list nodes is loading in NodeLoad method. It calls every times, when we click on "+" not Leaf node.
But we need to loaded complete list of nodes when the page refreshes. -
Oct 12, 2011, 10:52 AM
causes the same effect as a user click on "+".node.expand();
Similar Threads
-
[CLOSED] Reload tree node
By RCN in forum 2.x Legacy Premium HelpReplies: 2Last Post: May 16, 2012, 8:39 PM -
[CLOSED] [1.0] Tree node reload is very slow
By acrossdev in forum 1.x Legacy Premium HelpReplies: 9Last Post: Oct 28, 2010, 8:48 AM -
TreePanel.Reload
By ankit in forum 1.x HelpReplies: 0Last Post: Jun 11, 2010, 7:05 AM -
Reload TreePanel
By Maia in forum 1.x HelpReplies: 1Last Post: Jan 07, 2010, 4:39 AM -
TreePanel:Copying from one node to another node using drag and drop
By eighty20 in forum 1.x Legacy Premium HelpReplies: 5Last Post: Jan 25, 2009, 7:48 AM