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

4 posts, 0 answers
  1. Naveen
    Naveen avatar
    8 posts
    Member since:
    Apr 2011

    Posted 12 Apr 2011 Link to this post

    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.
  2. Dean
    Dean avatar
    43 posts
    Member since:
    Jun 2009

    Posted 12 Apr 2011 Link to this post

    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>
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Naveen
    Naveen avatar
    8 posts
    Member since:
    Apr 2011

    Posted 13 Apr 2011 Link to this post

    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.

  5. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 15 Apr 2011 Link to this post

    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.

Back to Top