Sorting folders

5 posts, 0 answers
  1. Jerry
    Jerry avatar
    44 posts
    Member since:
    Mar 2012

    Posted 30 Apr 2012 Link to this post

    I'm using a radfileexplorer to display a list of folders that have pdf files within them.  My folders are named for the year that pdf file is about so I have folders from 2005-2012. Within vs2008 it orders my folders from 2005 down to 2012 and that is how it displays in my radfileexplorer.   I need to have 2012 be the top folder going down to 2005 and i'm not sure how I can achieve this.

    Instead of listing like this:
    2005
    2006
    2007
    .
    2012

    I need it to list like this:
    2012
    2011
    2010
    .
    2005

    Thank you for any help
  2. jumpstart
    jumpstart avatar
    479 posts
    Member since:
    Nov 2011

    Posted 02 May 2012 Link to this post

    Jerry:

    You can reference this forum thread for insights on how to sort the folders by name and descending:

    Programmatically sort by filename

    Add this JavaScript to your .aspx markup:
    <script type="text/javascript">
    function OnFileExplorerClientLoad(oExplorer, args)
    {
        var masterTable = oExplorer.get_grid().get_masterTableView();
     
        masterTable.sort("Name DESC");
    }
    </script>

    and wire it to the RadFileExplorer's "OnClientLoad" event:
    <telerik:RadFileExplorer ID="RadFileExplorer1" runat="server" Height="500px" Width="804px"
        Skin="Forest" OnClientLoad="OnFileExplorerClientLoad">
        <Configuration SearchPatterns="*.*" MaxUploadFileSize="20480000" UploadPaths="~/Thumbs/"
            ViewPaths="~/Thumbs/" DeletePaths="~/Thumbs/"></Configuration>
    </telerik:RadFileExplorer>

    This will sort the folders and files displayed in the right side Grid Window by name in descending order.

    Let me know if this helps!
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jerry
    Jerry avatar
    44 posts
    Member since:
    Mar 2012

    Posted 02 May 2012 Link to this post

    jumpstart,

    Thank you that worked for the right side.  How do I get the left side to be sorted the same way?
    Can I have just the folders sorted descendingly but the files be sorted alphabetically?

    Is there a way to hide the left side and not allow the users to view that?

    Thank you
  5. jumpstart
    jumpstart avatar
    479 posts
    Member since:
    Nov 2011

    Posted 02 May 2012 Link to this post

    Jerry:

    Resorting the TreeView is more complex and is covered in this forum thread. You have to manually resort the list before passing it to the RadFileExplorer.Configuration.ViewPaths = viewPaths; assignment.

    Hiding the TreeView is the easier option for you.

    You can reference the FileExplorer/First Look online demo for an understanding of how to customize your RadFileExplorer instance. In this demo, you can see how to hide the TreeView.

    Here's some C# code to assist:
    using System;
    using System.IO;
     
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
     
            RadFileExplorer1.VisibleControls = GetVisibleControls(); 

        }
     
        private Telerik.Web.UI.FileExplorer.FileExplorerControls GetVisibleControls()
        {
            Telerik.Web.UI.FileExplorer.FileExplorerControls explorerControls = 0;
     
            explorerControls |= Telerik.Web.UI.FileExplorer.FileExplorerControls.AddressBox;
            explorerControls |= Telerik.Web.UI.FileExplorer.FileExplorerControls.Grid;
            explorerControls |= Telerik.Web.UI.FileExplorer.FileExplorerControls.Toolbar;
            //explorerControls |= Telerik.Web.UI.FileExplorer.FileExplorerControls.TreeView;
            explorerControls |= Telerik.Web.UI.FileExplorer.FileExplorerControls.ContextMenus;
            return explorerControls;
     
        }
    }

    See the attached image for display.

    Hope this helps!
  6. Tc Blaize
    Tc Blaize avatar
    3 posts
    Member since:
    Mar 2013

    Posted 14 Mar 2013 Link to this post

    This worked for me.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017