This is a migrated thread and some comments may be shown as answers.

Server Folder/File Structure in Treeview

9 Answers 461 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kurosh
Top achievements
Rank 1
Kurosh asked on 14 Jun 2011, 10:06 AM
I've just started evaluating the telerik radcontrols for silverlight and so far I am very impressed. I have run into an issue and I was hoping that someone could help me resolve this.

Problem: I need to traverse through folders and files located in a folder under the root of a web application and populate the radtreeview based on folder/file names. Populating the treeview is not an issue as I will be doing that in the code behind. However I am not sure about accessing the server folder/file structure and getting the paths and folder/file names.

Any help would be greatly appreciated and thanks in advance.
-Kurosh

9 Answers, 1 is accepted

Sort by
0
Accepted
Petar Mladenov
Telerik team
answered on 17 Jun 2011, 11:50 AM
Hello Kurosh,


I prepared a sample for which uses WCF RIA Services. I created a service method that iterates over a Folder in the WebSolution and returns a HIerarchy of Objects ( ObservableCollection<DataItems>) that is used in the client to show a hierarchical data in the RadTreeView. Please examine the solution and let us know if it helped you.

Regards,
Petar Mladenov
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
0
Kurosh
Top achievements
Rank 1
answered on 17 Jun 2011, 11:19 PM
Much Thanks! Your solution worked like a charm.

Cheers!
Kurosh
0
Chandu
Top achievements
Rank 2
answered on 12 Sep 2012, 02:18 PM
Hello Petar,

I have Worked on your sample, its working fine and i am having one issue, I need to traverse through folders and files located in a folder and inside of that folder up to the last traverse. 
Below is the scenario for my requirement.
Ex: Folder1-->Folder2-->Folder3-->Folder4-->FileName I need to traverse upto folder N..

Thanks in Advance

0
Petar Mladenov
Telerik team
answered on 17 Sep 2012, 08:27 AM
Hello Chandu,

 The following recursive code should do the work, no changes in XAML (SL project):

private DirectoryInfo startDirectory = new DirectoryInfo(@"C:\Users\pmladenov\Desktop\279102_TreeViewFoldersInWebPart\TreeViewFolders.Web\FolderA");
        private string startDirectoryString = "FolderA";
        public void DoWork()
        {
        }
 
        public ObservableCollection<DataItem> GetSomeData()
        {
            if (startDirectory != null)
            {
                ObservableCollection<DataItem> collection = new ObservableCollection<DataItem>();
                DataItem dataItem = new DataItem() { Name = startDirectoryString };
                this.AddChildCollection(dataItem, startDirectory);
                collection.Add(dataItem);
                return collection;
            }
            return null;
        }
 
        private void AddChildCollection(DataItem dataItem, DirectoryInfo currDirectory)
        {
            foreach (DirectoryInfo item in currDirectory.GetDirectories())
            {
                DataItem child = new DataItem()
                {
                    Name = item.Name.ToString()
                };
                this.AddChildCollection(child, new DirectoryInfo(item.FullName));
                dataItem.Children.Add(child);
            }
        }

Regards,
Petar Mladenov
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

0
Chandu
Top achievements
Rank 2
answered on 17 Sep 2012, 09:29 AM

Many many thanks petar,it is working perfect

thanks a lot
0
Pablo
Top achievements
Rank 1
answered on 04 Dec 2014, 03:59 AM

I have a question
to view files in the trewview

Carpeta_SubCarpeta_SubSubCarpeta_NombreArchivo  how I can do
0
Petar Mladenov
Telerik team
answered on 05 Dec 2014, 08:13 AM
Hi Pablo,

I am not sure I completely understand this scenario. The RadTreeView provides ItemTemplateSelector ItemContainerStyleSelector which allows you to set different templates / styles on the different levels.
If this does not answer your question, is it possible for you to open a new support thread with more details about your specific scenario. Thank you in advance.

Regards,
Petar Mladenov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Pablo
Top achievements
Rank 1
answered on 05 Dec 2014, 06:24 PM
OK sorry atacch example   of What I want to do whit wcf  whit RadTreView
0
Petar Mladenov
Telerik team
answered on 09 Dec 2014, 08:12 AM
Hi Pablo,

In your picture I can see a File / Folder tree structure and that is why I have attached a sample project implementing such structure with RadTreeView. Let us know if this is your requirement.

Regards,
Petar Mladenov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
General Discussions
Asked by
Kurosh
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Kurosh
Top achievements
Rank 1
Chandu
Top achievements
Rank 2
Pablo
Top achievements
Rank 1
Share this question
or