TreeView Node does not get removed

Answered
0
0

Hey

I have the situation, where I load orders from customers and show them as TreeView.

I try to load only the first couple of orders and when the customer has more then a specific amount of orders, then I show a special treeview node.

When this special treeview node is clicked, then the next orders get loaded (like paging)

The issue now is, that the specific treeview node does not get removed from the list.

I use the following code:

Dim locLoadAllTreeNode As New Wisej.Web.TreeNode With {.Name = String.Format(“{0}.{1}”, “LoadAllOrders”, locInformation),
.CheckBox = False,
.ImageKey = “LoadAll”}
            AddHandler locLoadAllTreeNode.NodeMouseClick, Sub(s As Object, e As EventArgs)
Dim locActualNode = DirectCast(s, Wisej.Web.TreeNode)
If locActualNode.Name.StartsWith(“LoadAll”) Then
tvCustomerOverview.ShowLoader = True
‘ Here comes the code to load more orders ….
                                                                  tvCustomerOverview.Nodes.Remove(locActualNode)
tvCustomerOverview.ResumeLayout()
tvCustomerOverview.ShowLoader = False
End If
End Sub
It seems to be a bug (I think)
THX
  • You must to post comments
Best Answer
0
0

I tried but I can’t reproduce. I didn’t understand exactly what the flow is from the code you posted. I did this:

private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
this.treeView1.Nodes.Add(“One”);
this.treeView1.Nodes.Add(“Two”);
this.treeView1.Nodes.Remove(e.Node);
}

And it works fine all the times.

Additionally, the code you pasted seems to come from Winforms which didn’t support “lazy” loading of nodes. Also, although Wisej does a great job in hiding the fact that it’s a web applications, it’s still a web application and nothing happens on the client until the request is completed – setting ShowLoader = true/false in the same code execution flow will simple update the client with false (the last value).

A better approach is to set a parent node to be a “lazy” load node:

  • Set the IsParent property of a node to true. It will make the node appear to be a parent without having to created the child nodes.
  • You can set the ShowLoader property of the same node (not the treeview but the node) to true. This will automatically show the loader only on that node while expanding – which is a common UI techinique.
  • Handle either the BeforeExpanding or AfterExpanding events and populate the child nodes. Wisej will automatically turn off the loader when the parent node has children.

HTH

 

 

  • You must to post comments
0
0

Hey

THX – you are right. It is working pretty well, when I try to remove from the correct node…

Sorry, was my mistake!

 

  • Eric Mathay
    Here is how I do it. if (treeView1.SelectedNode.Parent == null) { treeView1.Nodes.Remove(treeView1.SelectedNode); } else { TreeNode SelectedParent = treeView1.SelectedNode.Parent; treeView1.SelectedNode.Parent.Nodes.Remove(treeView1.SelectedNode); treeView1.SelectedNode = SelectedParent; }
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.