Hello all,
I've looked through the site a bit and found some info, but nothing that was exactly my problem, so here goes.
I have two treeviews TreeViewStart and TreeViewEnd. TreeViewStart is used kind of like a source for children. I have built this to be Load On Demand, and that part works wonderfully. I have also built it so that I can drag and drop a node and all its children to TreeViewEnd. That also works fine.
My problem, is that after the user has selected how the treeview should be (TreeViewEnd) using nodes from TreeViewStart, I needed to get the xml of that tree. So when the user clicks a button at the bottom I run the .GetXml function and get back my string. The problem with this is that I only get back information on the already expanded nodes. I believe this problem to be due to the load on demand and the non-existance of child nodes. The .ExpandAll() doesnt seem to work for me probably for the same reason.
Is there a way to make it so that when the user clicks the "Complete" button, that it will Expand all nodes on TreeViewEnd so that the .GetXml return string is accurate without forcing the user to click through all the child nodes? Below are some snippets of code.
Thanks in advance.
I've looked through the site a bit and found some info, but nothing that was exactly my problem, so here goes.
I have two treeviews TreeViewStart and TreeViewEnd. TreeViewStart is used kind of like a source for children. I have built this to be Load On Demand, and that part works wonderfully. I have also built it so that I can drag and drop a node and all its children to TreeViewEnd. That also works fine.
My problem, is that after the user has selected how the treeview should be (TreeViewEnd) using nodes from TreeViewStart, I needed to get the xml of that tree. So when the user clicks a button at the bottom I run the .GetXml function and get back my string. The problem with this is that I only get back information on the already expanded nodes. I believe this problem to be due to the load on demand and the non-existance of child nodes. The .ExpandAll() doesnt seem to work for me probably for the same reason.
Is there a way to make it so that when the user clicks the "Complete" button, that it will Expand all nodes on TreeViewEnd so that the .GetXml return string is accurate without forcing the user to click through all the child nodes? Below are some snippets of code.
Thanks in advance.
<table border="1" cellspacing="0" cellpadding="0" width="100%"><tr> |
<!-- FROM --> |
<td align="left" valign="middle" width="49%"> |
<rad:RadTreeView ID="TreeViewStart" EnableDragAndDrop="True" OnNodeDrop="RadTreeView1_HandleDrop" LoadingStatusPosition="BelowNodeText" OnNodeExpand="TreeViewStart_NodeExpand" OnNodeClick="TreeViewStart_NodeClick" runat="server"> |
<Nodes> |
<rad:RadTreeNode Text="Home" ExpandMode="ServerSideCallBack" Value="-1" /> |
</Nodes> |
</rad:RadTreeView> |
</td> |
<!-- SPACER --> |
<td width="2%" /> |
<!-- TO --> |
<td align="left" valign="middle" width="49%"> |
<rad:RadTreeView ID="TreeViewEnd" EnableDragAndDrop="True" LoadingStatusPosition="BelowNodeText" OnNodeExpand="TreeViewEnd_NodeExpand" OnNodeClick="TreeViewStart_NodeClick" runat="server"> |
<Nodes> |
<rad:RadTreeNode Text="Home" ExpandMode="ServerSideCallBack" Value="-1" /> |
</Nodes> |
</rad:RadTreeView> |
</td> |
</tr></table> |
<br /> |
<br /> |
<br /> |
<asp:Button ID="btnGetXML" Text="Get XML String" OnClick="btnGetXML_Click" runat="server" /> |
#region "Private Methods" |
private void LoadChildNodes(usp_Selectappdata_Role_Recursive NodeRequest, ref RadTreeNodeEventArgs e) |
{ |
Selectappdata_Role_RecursiveDS.usp_Selectappdata_Role_RecursiveDataTable ChildNodes = Vault<LookUpUtil>().RoleTreeViewSelect(NodeRequest); |
foreach (Selectappdata_Role_RecursiveDS.usp_Selectappdata_Role_RecursiveRow row in ChildNodes) |
{ |
RadTreeNode node = new RadTreeNode(); |
node.Text = row.RoleName; |
node.Value = row.AppdataRoleId.ToString(); |
if (row.ChildCount > 0) |
{ |
node.ExpandMode = TreeNodeExpandMode.ServerSide; |
} |
e.Node.Nodes.Add(node); |
} |
e.Node.Expanded = true; |
} |
#endregion |
protected void Page_Load(object sender, EventArgs e) |
{ |
} |
protected void TreeViewStart_NodeExpand(object sender, RadTreeNodeEventArgs e) |
{ |
usp_Selectappdata_Role_Recursive NodeRequest = new usp_Selectappdata_Role_Recursive(); |
if (e.Node.Value != "-1") |
{ |
NodeRequest.Rolelevel = 1; |
NodeRequest.RoleLevelCriteria = "="; |
NodeRequest.AppdataRoleId = Convert.ToInt32(e.Node.Value); |
} |
else |
{ |
{ |
NodeRequest.Rolelevel = 0; |
NodeRequest.RoleLevelCriteria = "="; |
} |
} |
LoadChildNodes(NodeRequest, ref e); |
} |
protected void TreeViewEnd_NodeExpand(object sender, RadTreeNodeEventArgs e) |
{ |
usp_Selectappdata_Role_Recursive NodeRequest = new usp_Selectappdata_Role_Recursive(); |
if (e.Node.Value != "-1") |
{ |
NodeRequest.Rolelevel = 1; |
NodeRequest.RoleLevelCriteria = "="; |
NodeRequest.AppdataRoleId = Convert.ToInt32(e.Node.Value); |
LoadChildNodes(NodeRequest, ref e); |
} |
} |
protected void TreeViewStart_NodeClick(object sender, RadTreeNodeEventArgs e) |
{ |
} |
protected void RadTreeView1_HandleDrop(object sender, RadTreeNodeDragDropEventArgs e) |
{ |
RadTreeNode sourceNode = e.SourceDragNode; |
RadTreeNode destNode = e.DestDragNode; |
RadTreeViewDropPosition dropPosition = e.DropPosition; |
string result = ""; |
if (destNode != null)//drag&drop is performed between trees |
{ |
if (sourceNode.TreeView.SelectedNodes.Count <= 1) |
{ |
if (!sourceNode.IsAncestorOf(destNode)) |
{ |
//result += "<b>" + sourceNode.Text + "</b>" + ";"; |
sourceNode.Owner.Nodes.Remove(sourceNode); |
destNode.Nodes.Add(sourceNode); |
} |
} |
else if (sourceNode.TreeView.SelectedNodes.Count > 1) |
{ |
foreach (RadTreeNode node in TreeViewStart.SelectedNodes) |
{ |
if (!node.IsAncestorOf(destNode)) |
{ |
//result += "<b>" + node.Text + "</b>" + ";"; |
node.Owner.Nodes.Remove(node); |
destNode.Nodes.Add(node); |
} |
} |
} |
destNode.Expanded = true; |
//DragMessage.Text = "You dragged node(s)" + result + " onto node <b>" + destNode.Text + "</b>"; |
sourceNode.TreeView.ClearSelectedNodes(); |
} |
} |
protected void btnGetXML_Click(object sender, EventArgs e) |
{ |
string preFix = TreeViewEnd.GetXml(); |
//preFix.Replace("<", "<"); |
//preFix.Replace(">", ">"); |
lblXMLString.Text = "Code: " + preFix; |
System.IO.TextWriter asd = new System.IO.StreamWriter(@"C:\exper\test.txt"); |
asd.Write(preFix); |
asd.Close(); |
} |