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

Do Not Show Sub Folders

5 Answers 134 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Frank
Top achievements
Rank 1
Frank asked on 15 Dec 2016, 09:25 PM

In the RadFileExplorer I am trying to figure out how to hide the subfolders.

currently I have this which is filter and only showing the file types I want to show.

I have tried to send an empty Array into the Directories but it is still shwing all the sub folders.

public class ExtendedFileProvider : FileSystemContentProvider
        {
            //constructor must be present when overriding a base content provider class
            //you can leave it empty
            public ExtendedFileProvider(HttpContext context, string[] searchPatterns, string[] viewPaths, string[] uploadPaths, string[] deletePaths, string selectedUrl, string selectedItemTag)
                : base(context, searchPatterns, viewPaths, uploadPaths, deletePaths, selectedUrl, selectedItemTag)
            {
            }
            public override DirectoryItem ResolveDirectory(string path)
            {
                //get the directory information
                DirectoryItem baseDirectory = base.ResolveDirectory(path);
                //remove files that we do not want to see
                List<FileItem> files = new List<FileItem>();
                foreach (FileItem file in baseDirectory.Files)
                {
                    if (file.Name.Contains(".pdf") || file.Name.Contains(".doc") || file.Name.Contains(".docx") || file.Name.Contains(".zip"))
                    {
                        files.Add(file);
                    }
                }
                List<DirectoryItem> dirs = new List<DirectoryItem>();
                dirs.Clear();       
 
                DirectoryItem newDirectory = new DirectoryItem(baseDirectory.Name, baseDirectory.Location, baseDirectory.FullPath, baseDirectory.Tag, baseDirectory.Permissions, files.ToArray(),dirs.ToArray());
                //return the updated directory information
                return newDirectory;
            }
        }

5 Answers, 1 is accepted

Sort by
0
Frank
Top achievements
Rank 1
answered on 15 Dec 2016, 09:27 PM
Forgot to add I am only showing the ListView, Grid, and Toolbar. 
0
Frank
Top achievements
Rank 1
answered on 15 Dec 2016, 09:49 PM
Here is my fileexplorer I need to hide the folders Cycle 1 Cycle 2
0
Accepted
Vessy
Telerik team
answered on 16 Dec 2016, 12:52 PM
Hello Frank,

I have just answered your support ticket on the matter - for convenience I am pasting my answer here as well:

The ResolveDirectory method is responsible for the files inside the directory. In order to hide the sub folders you will need to override the ResolveRootDirectoryAsTree() method in a similar way:
public class ExtendedFileProvider : FileSystemContentProvider
{
    public ExtendedFileProvider(HttpContext context, string[] searchPatterns, string[] viewPaths, string[] uploadPaths, string[] deletePaths, string selectedUrl, string selectedItemTag)
        : base(context, searchPatterns, viewPaths, uploadPaths, deletePaths, selectedUrl, selectedItemTag) { }
 
    public override DirectoryItem ResolveRootDirectoryAsTree(string path)
    {
       DirectoryItem originalFolder = base.ResolveRootDirectoryAsTree(path);
       DirectoryItem newFolder = new DirectoryItem(originalFolder.Name, originalFolder.Location, originalFolder.FullPath, originalFolder.Tag, originalFolder.Permissions, originalFolder.Files, new DirectoryItem[] { });
 
        return newFolder;
    }
}


Regards,
Vessy
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Frank
Top achievements
Rank 1
answered on 16 Dec 2016, 03:14 PM
Thanks that works
0
Vessy
Telerik team
answered on 16 Dec 2016, 04:47 PM
Hi,

You are welcome, Frank - I am glad the provided solution is working for you.

Regards,
Vessy
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
FileExplorer
Asked by
Frank
Top achievements
Rank 1
Answers by
Frank
Top achievements
Rank 1
Vessy
Telerik team
Share this question
or