Hello,
I am looking for a VB.NET Example of using the webdatatree on the filesystem with load on demand. I am trying to use it like the windows explorer for folders.
I love your products!!!
Thanks!!
Jack
Hi Jack,
I'm glad that you like the products!
I would recommend you to use manual load on demand for that case, here is a short sample which you can use as a starting point:
<form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <ig:WebDataTree ID="WebDataTree1" runat="server" Height="300px" Width="200px"> </ig:WebDataTree></form>
And code behind:
Imports System.IOImports Infragistics.Web.UI.NavigationControls
Partial Class _Default Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then PopulateDirectory(WebDataTree1.Nodes, Server.MapPath("~/")) End If End Sub
Protected Sub WebDataTree1_NodePopulate(ByVal sender As Object, ByVal e As Infragistics.Web.UI.NavigationControls.DataTreeNodeEventArgs) Handles WebDataTree1.NodePopulate PopulateDirectory(e.Node.Nodes, e.Node.DataPath) End Sub
Sub PopulateDirectory(ByVal nodes As DataTreeNodeCollection, ByVal path As String) Dim info As DirectoryInfo info = New DirectoryInfo(path)
For Each dir As DirectoryInfo In info.GetDirectories() Dim folderNode As DataTreeNode folderNode = New DataTreeNode() folderNode.Text = dir.Name folderNode.DataPath = String.Format("{0}/{1}", path, dir.Name) folderNode.IsEmptyParent = dir.GetDirectories().Length > 0 nodes.Add(folderNode) Next End SubEnd Class
Hope that helps!
Is there a timeout on the nodepopulate event? I ask this question because I have stepped through my nodepopulate event and can see my nodes being added to the tree, but after the sub is over my tree only shows the data loading message still? I do know that my function to return the data needed to populate the tree takes some time. I have also noticed that if I step to slowly through a nodepopulate event that I get the same behavior. I can see the data populated and the nodes added but the never make it to client. In this example the "info.getdirectories" function would take some time.