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

Rename a File or Folder by Double clicking on the Grid of file Explorer

3 Answers 184 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Naveen
Top achievements
Rank 1
Naveen asked on 12 Apr 2011, 02:42 PM
Hi,

I am using the latest version of File Explorer.
I want to rename a file or folder by double clicking the item on the grid of File Explorer.

Can you please help?

Thanks & Regards,
Naveen.

3 Answers, 1 is accepted

Sort by
0
Dean
Top achievements
Rank 2
answered on 12 Apr 2011, 08:45 PM
Hi Naveen,

Please try the following ASP Markup, it will allow you to double click on a file or folder and show the rename window. Please let me know if this works ok.

ASP Markup

<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Width="300px" LoadingPanelID="RadLoadingPanel1">
    <telerik:RadCodeBlock runat="server">
        <script language="javascript" type="text/javascript">
            function OnClientFileOpen(sender, args) {
                // Cancel the request to open the file/folder
                args.set_cancel(true);
 
                var explorer = $find("<%=RadFileExplorer1.ClientID %>"); //get reference to the fileexplorer
                if (!explorer) return;
 
                var grid = explorer.get_grid(); //get reference to the grid component
                var treeView = explorer.get_tree(); //get reference to the treeview component
 
                var gridSelectedItems = grid.get_selectedItems();
 
                if (grid.get_selectedItems().length > 1) return; //in case multiple items are selected cancel the execution of the rename
 
                if (grid.get_selectedItems().length == 1) {
                    explorer._gridContextMenuSelectedItem = grid.get_selectedItems()[0];
                    explorer.get_gridContextMenu().findItemByValue("Rename").click();
 
                    return;
                }
 
                if (grid.get_selectedItems().length < 1) {
                    treeView.get_selectedNode().startEdit();
                    return;
                }
            }
        </script>
    </telerik:RadCodeBlock>
    <telerik:RadAjaxLoadingPanel ID="RadLoadingPanel1" runat="server" Skin="Default">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadFileExplorer ID="RadFileExplorer1" runat="server" OnClientFileOpen="OnClientFileOpen">
        <Configuration ViewPaths="~/Images" UploadPaths="~/Images" />
    </telerik:RadFileExplorer>
</telerik:RadAjaxPanel>
0
Naveen
Top achievements
Rank 1
answered on 13 Apr 2011, 08:02 AM
Hi Dean,

I have tried the below code.It is working as expected.
But here we are overriding the onClientFileOpen functionality.
I don't want to override it.
When I will select a item(say picture) in Grid and click on Open icon on File Explorer Tool Bar it should show me Preview Window and if I double click the same item it should show me Rename Confirmation Box rather than Preview Window.

Can you please help?

Thanks & Regards,
Naveen.

0
Dobromir
Telerik team
answered on 15 Apr 2011, 09:48 AM
Hi Naveen,

You can assign a handler to the RowDoubleClick event of RadGrid component to execute the rename functionality, but please note that navigating to a folder from the grid is also executed on the double click event and this may cause side effects. You can assign handler to the double click event using the following approach:
<telerik:RadFileExplorer ID="RadFileExplorer1" runat="server" OnClientLoad="OnClientLoad">
    <Configuration ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" />
</telerik:RadFileExplorer>
 
<script type="text/javascript">
    function OnClientLoad(explorer, args)
    {
        var grid = explorer.get_grid();
        grid.add_rowDblClick(function (sender, args)
        {
            //implement custom functionality here
        });
    }
</script>


Best wishes,
Dobromir
the Telerik team

Browse the vast support resources we have to jump start 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.

Tags
FileExplorer
Asked by
Naveen
Top achievements
Rank 1
Answers by
Dean
Top achievements
Rank 2
Naveen
Top achievements
Rank 1
Dobromir
Telerik team
Share this question
or