Can FileExplorer have a DB as source?

4 posts, 0 answers
  1. Jason Bourdette
    Jason Bourdette avatar
    77 posts
    Member since:
    Jan 2010

    Posted 24 Apr 2010 Link to this post

    I have a database table that represents file paths on a systems.

    I just want to show the paths from the database. Can I use FileExplorer for this. Does the datasource for FileExplorer have to be a physical folder on a real machine.

    I currently load my database and I wrote some C# code to run over the flat table to put everything back into and asp.net tree view control, but the fileexplorer you guys build it much cooler looking then then the asp.net tree view control.

    thanks
    jason
  2. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 27 Apr 2010 Link to this post

    Hi Jason,

    I believe that this online demo will be of help.

    All the best,
    Fiko
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jason Bourdette
    Jason Bourdette avatar
    77 posts
    Member since:
    Jan 2010

    Posted 12 May 2010 Link to this post

    I have been working on this for a while now, and have not been able to figure this out. If any one can help that would be great. I'm posting the code I was previously using to achieve a file_explorer type control but I'd much rather use the telerik file explorer.


    previously used an asp.net treeview  - want to use RadFileExplorer
        private void PopulateTopNode()  
        {  
            string selectCommand = "SELECT id,parent,value FROM DIRS WHERE parent IS NULL ORDER BY hasChild DESC";  
            string conString = ConfigurationManager.ConnectionStrings["vistasp1ConnectionString"].ConnectionString;  
            SqlDataAdapter dad = new SqlDataAdapter(selectCommand, conString);  
            DataTable dtblMessages = new DataTable();  
            dad.Fill(dtblMessages);  
     
            foreach (DataRow row in dtblMessages.Rows)  
            {  
                string parent = row["value"].ToString();  
                TreeNode newnewNode = new TreeNode(row["value"].ToString(), parent);  
                newNode.PopulateOnDemand = true;  
                newNode.Expanded = true;  
                newNode.SelectAction = TreeNodeSelectAction.Expand;  
                newNode.ImageUrl = "images/WebResource2.gif";  
                TreeView1.Nodes.Add(newNode);  
            }  
        }  
     
        protected void TreeView1_TreeNodePopulate(object sender, TreeNodeEventArgs e)  
        {  
            string selectCommand = "SELECT id,parent,value,hasChild FROM DIRS WHERE parent=@parent ORDER BY hasChild DESC";  
            string conString = ConfigurationManager.ConnectionStrings["vistasp1ConnectionString"].ConnectionString;  
            SqlDataAdapter dad = new SqlDataAdapter(selectCommand, conString);  
            dad.SelectCommand.Parameters.AddWithValue("@parent", e.Node.Value);  
            DataTable dtblMessages = new DataTable();  
            dad.Fill(dtblMessages);  
     
            foreach (DataRow row in dtblMessages.Rows)  
            {  
                string hasChild = row["hasChild"].ToString();  
                string parent = row["parent"].ToString() + @"\" + row["value"].ToString();  
                TreeNode newnewNode = new TreeNode(row["value"].ToString(), parent);  
                if (hasChild == "0")  
                {  
                    newNode.ImageUrl = "images/WebResource3.gif";  
                    newNode.SelectAction = TreeNodeSelectAction.Select;  
                    newNode.Expand();  
                    newNode.NavigateUrl = "details.aspx?path=" + newNode.Value;  
                    newNode.Expanded = true;  
                }  
                else  
                {  
                    newNode.SelectAction = TreeNodeSelectAction.Expand;  
                    newNode.Expanded = false;  
                    newNode.PopulateOnDemand = true;  
                }  
     
                e.Node.ChildNodes.Add(newNode);  
            }  
        }  
     
     
     
    <asp:TreeView ID="TreeView1" runat="server"    
                        OnTreeNodePopulate="TreeView1_TreeNodePopulate" ImageSet="XPFileExplorer"   
                        NodeIndent="15" ShowLines="false">  
                        <ParentNodeStyle Font-Bold="False" /> 
                        <HoverNodeStyle Font-Underline="False" ForeColor="Black" /> 
                        <SelectedNodeStyle Font-Underline="False"   
                            Font-Names="Tahoma" Font-Size="8pt" ForeColor="Black"   
                            HorizontalPadding="2px" NodeSpacing="0px" VerticalPadding="2px" /> 
                        <NodeStyle Font-Names="Tahoma" Font-Size="8pt" ForeColor="Black"   
                            Horizont 

    than in the page load function I just called the PopulateTopNode()


    I looked into overriding:
     public override Telerik.Web.UI.Widgets.DirectoryItem ResolveRootDirectoryAsTree(string path)  
       {  
           throw new NotImplementedException();  
       }  
       public override Telerik.Web.UI.Widgets.DirectoryItem ResolveDirectory(string path)  
       {  
           throw new NotImplementedException();  
       }  
       
    but these return DirectoryItem which got confusing cause i'm not travering a file system.

    Then I thought maybe just do the same thing I was doing before but RadFileExplorer.Treeview doesnt seem to have a OnTreeNodePopulate function


    Any help would be great. I just want a read only file explorer where the object in the tree have hyperlinks. No file uploads, file copies or anything, but my data source is a database with schema ( id, parent, value, hasChild ).

    Thanks
    Jason
  5. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 14 May 2010 Link to this post

    Hello Jason,

    The RadFileExplorer control uses a ContentProvider model in order to load its content and the code used to populate a standard TreeView control will not work in this case. Instead, you need to implement a custom FileBrowserContentProvider which acts as an interface between the datasource (database in your case) and the RadFileExplorer control. More information about implementing a custom provider can be found on this online page.

    I hope this helps.

    Greetings,
    Fiko
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top