Do Not Show Sub Folders

6 posts, 1 answers
  1. Frank
    Frank avatar
    95 posts
    Member since:
    Mar 2012

    Posted 15 Dec 2016 Link to this post

    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;
                }
            }
  2. Frank
    Frank avatar
    95 posts
    Member since:
    Mar 2012

    Posted 15 Dec 2016 Link to this post

    Forgot to add I am only showing the ListView, Grid, and Toolbar. 
  3. Frank
    Frank avatar
    95 posts
    Member since:
    Mar 2012

    Posted 15 Dec 2016 Link to this post

    Here is my fileexplorer I need to hide the folders Cycle 1 Cycle 2
  4. Answer
    Vessy
    Admin
    Vessy avatar
    1601 posts

    Posted 16 Dec 2016 Link to this post

    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.
  5. Frank
    Frank avatar
    95 posts
    Member since:
    Mar 2012

    Posted 16 Dec 2016 Link to this post

    Thanks that works
  6. Vessy
    Admin
    Vessy avatar
    1601 posts

    Posted 16 Dec 2016 Link to this post

    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.
Back to Top