iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Hi,
I have WebTreeView with LoadOnDemand enabled. Is it posibble to load several nodes from server on node expand (not on same level)? In codebehind something like this
protected void WebTreeView1_InitializeChildNodes(object sender, ISNet.WebUI.WebTreeView.WebTreeViewNodeEventArgs e) { WebTreeViewNode node1 = new WebTreeViewNode("level 1"); WebTreeViewNode node2 = new WebTreeViewNode("level 2"); node1.Nodes.Add(node2); e.Node.Nodes.Add(node1); }
This load only node1.
In our application we have button, which expand tree to show certain nodes (by type). Nodes can be on any level. We use classic ASP TreeView where this is no problem - loadondemand, but on server i can prepare nodes and it worked.
With WebTreeView i must use "workaround" - on server (button click event) prepare all nodes and their path, save this for javascript and when page loads expand first node. Then WebTreeView have clientside event OnNodeExpand where i take next path to expand, find the node a and call Expand() on it. And so on, until all nodes are expanded. But it can take a long time, because its client - server comnunication for every node. Basicaly emulate user clicking.
Is this the only way to achive this?
Hello,I apologize for the late response.Basically, we can’t use “Load on Demand” scenario or feature in (TreeView) node that already has children (child node).I attached a page that contains ASP.Net TreeView to show how the “Load on Demand” feature of ASP.Net TreeView works.In this page, I add “OnTreeNodePopulate” server side event to the TreeView control.On the “Page_Load” server side event, I create the root node for the TreeView:
protected void Page_Load(object sender, EventArgs e){ if (!IsPostBack) { TreeNode rootNode = new TreeNode(); rootNode.Text = "Root"; rootNode.Value = "Level0"; rootNode.Expanded = true; rootNode.PopulateOnDemand = true; TreeView1.Nodes.Add(rootNode); } }
Then in “OnTreeNodePopulate” server side event I try to add two nodes with different depth level.
protected void TreeView1_TreeNodePopulate(object sender, TreeNodeEventArgs e) { TreeNode newNode = new TreeNode(); newNode.Text = "Level One"; newNode.Value = "Level1"; newNode.PopulateOnDemand = false; TreeNode newNode2 = new TreeNode(); newNode2.Text = "Level Two"; newNode2.Value = "Level2"; newNode2.PopulateOnDemand = true; newNode.ChildNodes.Add(newNode2); e.Node.ChildNodes.Add(newNode); }
With this configuration the ASP.Net TreeView will work properly. However, if you try to modify the “PopulateOnDemand” property, in “newNode”, to “True”.You will get the warning message while you are trying to expand the root node.I attached the video regarding the result on my end as well.As you can see, the Intersoft WebTreeView have the same default behavior with ASP.Net TreeView, that the “Load on Demand” scenario or feature can’t be applied in (TreeView) node that already has children (child node).Due to that behavior, in this Load on Demand scenario, the WebTreeView will only load the parent node, not with its child node.Hope this helps.Regards,Hans K.
thanks for your time, you are right, in our scenario I can keep PopulateOnDemand = false for this nodes and I combine our two scenarios... But I can still do in ASP:TreeView this (basicaly ExpandToNode / ExpandToNodes functionality)
protected void TreeView1_TreeNodePopulate(object sender, TreeNodeEventArgs e) { TreeNode n = new TreeNode(); n.PopulateOnDemand = true; e.Node.ChildNodes.Add(n); if (...) // condition for nodes i want expand n.Expand(); // it calls resursively by treeview }
and it expand tree on server and send all nodes to client in 1 request (ExpandToNodes functionality). This doesnt work with WebTreeView. I can call n.Expand() on WebTreeView1_InitializeChildNodes but nothing happend - i know its not asp:TreeView, just asking if there is better way than "clicking" with javascript on nodes and generate many requests.
Another thing i notice is if I expand node (populateOnDemand) and it has no child the "plus" button didnt hide and also clientside event OnNodeExpand is not called (but this is maybe OK, nothing expanded)
Thanks
Hello,Thank you for the reply.Basically, in “Load on Demand” case, that is behavior in WebTreeView, you should load/render the parent node before you can load the child node.Regarding “the better workaround”, I still can’t get the better workaround than yours.Regarding “hide plus button”, perhaps you could hide the “plus” / expand button in “OnInitializeNode” server side event.Here’s the example snippet code how to hide the expand button:
protected void WebTreeView1_InitializeNode(object sender, WebTreeViewNodeEventArgs e){ // For example, this code will hide the node the have depth level equal to 3 if (e.Node.Depth == 3) e.Node.ChildNodeExpandable = false; }
Thank you.Regards,Hans K.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname