draf & drop to copy file not move?

7 posts, 0 answers
  1. Robert
    Robert avatar
    16 posts
    Member since:
    Feb 2016

    Posted 23 Mar Link to this post

    Any way to substitute drag&drop action for copy not to move?.
    thanks
  2. Vessy
    Admin
    Vessy avatar
    1380 posts

    Posted 25 Mar Link to this post

    Hi Robert,

    No, I am afraid that FileExplorer does not provide any option for such configuration. Nevertheless, you can achieve a similar behavior by canceling the FileExplroer's ClientMove event and copying manually the dragged item through the control's API:
    <telerik:RadFileExplorer ID="RadFileExplorer1" runat="server" EnableCopy="true" OnClientMove="onMove">
        <Configuration ViewPaths="~/Images" DeletePaths="~/Images" UploadPaths="~/Images" />
    </telerik:RadFileExplorer>
    <script>
        function onMove(fileExplorer, args) {
            var file = args.get_item();
            var path = args.get_newPath();
            var treeNode = fileExplorer.get_tree().findNodeByValue(path);
            var dirItem = fileExplorer.getFileExplorerItemFromNode(treeNode);
     
            setTimeout(function () {
                fileExplorer._addItemToCopiedPaths(file);
                fileExplorer.paste(dirItem);
            }, 100);
     
            fileExplorer.clearCopyItems();
            args.set_cancel(true);
        }
    </script>

    Regards,
    Vessy
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Wild
    Wild avatar
    10 posts
    Member since:
    Mar 2016

    Posted 28 Mar in reply to Vessy Link to this post

    Hi, I need also something like that but from fileexplorer2 to fileexplorer1 so

    I have tried you code and it works but after successful copy fileexplorer2

    remains in refreshing state and not ending like in picture. Fileexplorer1 is fine. I have tried to force refresh

    but didn't work. It does work though manually refreshing from the toolbar.

    How to fix that?  I have modified your code like below:

    function RadFileExplorer2_Move(fileExplorer, args) {

                var file = args.get_item();
                var path = args.get_newPath();
                var fileExplorer1 = $find("<%= RadFileExplorer1.ClientID%>");
                var treeNode = fileExplorer1.get_tree().findNodeByValue(path);
                var dirItem = fileExplorer1.getFileExplorerItemFromNode(treeNode);

                setTimeout(function () {
                    fileExplorer1._addItemToCopiedPaths(file);
                    fileExplorer1.paste(dirItem);
                 }, 100);

                fileExplorer1.clearCopyItems();
                args.set_cancel(true);
            }

     

    thanks

  5. Vessy
    Admin
    Vessy avatar
    1380 posts

    Posted 31 Mar Link to this post

    Hi Wild,

    This happens as the second FileExplorer does not have enough time to finalize its ajax requests, thus the request rised by the FileExplorer1 is canceling the AJAX request of RadFileExplorer2.

    Giving some more time to the paste() function of RadFileExplorer1 should allow both of the controls to update themselves successfully:
    function RadFileExplorer2_Move(fileExplorer, args) {
     
        var file = args.get_item();
        var path = args.get_newPath();
        var fileExplorer1 = $find("<%= RadFileExplorer1.ClientID%>");
        var treeNode = fileExplorer1.get_tree().findNodeByValue(path);
        var dirItem = fileExplorer1.getFileExplorerItemFromNode(treeNode);
     
        setTimeout(function () {
            fileExplorer1._addItemToCopiedPaths(file);
            fileExplorer1.paste(dirItem);
        }, 500);
     
     
        fileExplorer1.clearCopyItems();
        args.set_cancel(true);
    }


    Regards,
    Vessy
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  6. Wild
    Wild avatar
    10 posts
    Member since:
    Mar 2016

    Posted 31 Mar in reply to Vessy Link to this post

    Vessy,

    thank you very much, it worked. I needed to actually give it even more like 1000.

  7. Wild
    Wild avatar
    10 posts
    Member since:
    Mar 2016

    Posted 31 Mar Link to this post

    weird thing is though, most of the time it works now but sometimes happens right panel still hang, wonder how much I can extend that time....
  8. Vessy
    Admin
    Vessy avatar
    1380 posts

    Posted 01 Apr Link to this post

    Hi Robert,

    The time for finalizing the AJAX request of the initiating FileExplorer (respectively the needed timeout) depends on many factors (like the size of the copied files) and could be different each time. Unfortunately adding bigger timeout is the only way to achieve the target by you functionality for the moment.

    Regards,
    Vessy
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017