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

Files and Folders in RadFileExplorer

3 Answers 259 Views
Editor
This is a migrated thread and some comments may be shown as answers.
B
Top achievements
Rank 1
B asked on 23 Nov 2010, 12:48 PM
Hi,

We have implemented date sorting for the RadFileExplorer in the Image Manager tool of RadEditor. With this, the contents of our configured image path are sorted according to the date they were uploaded.  We have also enabled paging for the explorer. Currently we have a problem when the parent 'Images' path has both files and sub folders. In this case, RadFileExplorer seems to be always picking folders first rather than files. So, for example, if my page size was 5 and I have two subfolders and 5 files in my directory, the first page always shows the directories. This has become a problem when a new file is uploaded. We expect to see it at the head of the first page. However, we find that it is the head of a page somewhere down the line. This is happening only when there are subfolders in the parent directory.

Please advise!

3 Answers, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 25 Nov 2010, 04:31 PM
Hello,

I assume you have implemented the file sorting functionality using the RadFileExplorer's ExplorerPopulated event. Using this event will allow you to reorder the files on the currently displayed folder. To be able to sort all the files you need to implement custom content provider and override the ResolveDirectory() method, e.g.:
public class CustomFileBrowserProviderWithFilter : FileSystemContentProvider
{
    public CustomFileBrowserProviderWithFilter(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)
    {
        DirectoryItem originalFolder = base.ResolveDirectory(path);
        FileItem[] originalFiles = originalFolder.Files;
        List<FileItem> orderedFiles = new List<FileItem>();
 
        foreach (FileItem originalFile in originalFiles)
        {
            //implement custom file sorting
        }
 
        DirectoryItem newFolder = new DirectoryItem(originalFolder.Name, originalFolder.Location, originalFolder.FullPath, originalFolder.Tag, originalFolder.Permissions, orderedFiles.ToArray(), originalFolder.Directories);
 
        return newFolder;
    }
 
}


Best wishes,
Dobromir
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
B
Top achievements
Rank 1
answered on 21 Feb 2011, 12:57 PM

Hi,
We did try the above solution but it did not work for us when paging was enabled and there were folders within folders. The sorting was not very correct in that case. So, we disabled paging but we ran into other issues in IE (Firefox, Safari, Chrome handle the following perfectly/quickly)perfectly/quickly) .

If the directory has a lot of images in it (say, 50 or more, or perhaps the file sizes of the images are quite large), the launching of this tool will literally FREEZE the IE browser for 30-60 seconds (IE's windows-bar displays "(Not Responding)" if you try to click anywhere in the window). The RadEditor is a part of our online application where significant numbers of fairly novice users utilize it to build simple email content. So…the patience level of these authors is very low, and they often will simply attempt to close the browser, as they believe the system has crashed….when in fact, if they just waited 30-60 seconds the problem would go away. 

0
Dobromir
Telerik team
answered on 24 Feb 2011, 01:31 PM
Hi,

I will try to explain in more details how the content provider works. When a folder is loaded, the content provider first calls ResolveRootDirectoryAsTree() method to populate the subfolders then execute ResolveDirectory() method to populate the files. At the moment it is not possible to modify this behavior, thus it is not possible to list a file before the subfolders using the content provider. This can be achieved in the ExplorerPopulated event of RadFileExplorer, however, in this event the items that are available are only the items that will be displayed on the current page.

Now to the problem, do you experience the same loading time issue without the sorting of the files? How do you exactly implement the item sorting?

All the best,
Dobromir
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Editor
Asked by
B
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
B
Top achievements
Rank 1
Share this question
or