Sorting RadFileExplorer items by name

Article Info

Rating: 4

Article information

Article relates to

 RadEditor for ASP.NET AJAX,
 RadFileExplorer for ASP.NET AJAX,
 Telerik.Web.UI

Created by

 Rumen Zhekov



HOW-TO
Sorting RadFileExplorer items by name

SOLUTION
1) for RadFileExplorer:

To sort the FileExplorer items use the RadGrid's Client-Side API as follows:

<script type="text/javascript"
    function OnFileExplorerClientLoad(oExplorer, args) 
    
        var masterTable = oExplorer.get_grid().get_masterTableView(); 
   
        masterTable.sort("Name"); 
        // masterTable.sort("Size");  //sort the files by size
    
</script>

Attach the OnFileExplorerClientLoad function to the OnClientLoad event property of the RadFileExplorer control.

2) for RadEditor:

Register the external dialog files of RadEditor so that you can modify the FileBrowser.ascx file loaded in the RadEditor's FileBrowser managers (Image, Document, Flash, Media, Template, Silverlight). After that open the \EditorDialogs\FileBrowser.ascx file, locate the <telerik:RadFileExplorer> control and attach the OnFileExplorerClientLoad function below to the OnClientLoad event property of the RadFileExplorer control, e.g.

<telerik:RadFileExplorer ID="RadFileExplorer1" OnClientLoad="OnFileExplorerClientLoad" Height="450px" Width="400px" TreePaneWidth="150px"
runat="Server" EnableOpenFile="false" AllowPaging="true" />
<script type="text/javascript">
function OnFileExplorerClientLoad(oExplorer, args)
{
    var masterTable = oExplorer.get_grid().get_masterTableView(); 
    masterTable.sort("Name ASC"); //sort in ascending order
    //masterTable.sort("Name DESC"); //sort in descending order
}
</script>

3) for RadEditor for MOSS

Review the ExternalDialogsPath property help article and set the ExternalDialogsPath property in you respective ConfigFile.xml or ListConfigFile.xml, which are located in the /Program Files/Common Files/Microsoft Shared/web server extensions/wpresources/RadEditorSharePoint/5.x.x.0__1f131a624888eeed/Resources/ folder.

For example add the following code (5.x.x is the version of RadEditor for MOSS. Change the x.x with your version):
<property name="ExternalDialogsPath">/_wpresources/RadEditorSharePoint/5.x.x.0__1f131a624888eeed/Resources</property>

Copy the FileBrowser.ascx (in the help article of step one is explained how to obtain it) in the mentioned above folder.

Set the OnClientLoad property of telerik:RadFileExplorer with ID="RadFileExplorer1" so it looks like:
<telerik:RadFileExplorer ID="RadFileExplorer1" Height="450px" Width="400px" TreePaneWidth="150px" runat="Server" EnableOpenFile="false" AllowPaging="true" OnClientLoad="OnClientLoad"/>

Add the following javascript method in the source (for example in the MOSSEditorTools.js file placed in the Resources folder mentioned above):

function OnClientLoad(oExplorer, args)
{
    var oGrid = oExplorer.get_grid();
    var masterTableView = oGrid.get_masterTableView();
    masterTableView.sort("Name ASC");
}

Comments

If you'd like to comment on this KB article, please, send us a Support Ticket.
Thank you!

Please Sign In to rate this article.