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

draf & drop to copy file not move?

6 Answers 74 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 23 Mar 2016, 10:39 AM
Any way to substitute drag&drop action for copy not to move?.
thanks

6 Answers, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 25 Mar 2016, 03:00 PM
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.
0
Wild
Top achievements
Rank 1
answered on 28 Mar 2016, 10:06 AM

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

0
Vessy
Telerik team
answered on 31 Mar 2016, 11:15 AM
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.
0
Wild
Top achievements
Rank 1
answered on 31 Mar 2016, 07:45 PM

Vessy,

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

0
Wild
Top achievements
Rank 1
answered on 31 Mar 2016, 08:23 PM
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....
0
Vessy
Telerik team
answered on 01 Apr 2016, 03:09 PM
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.
Tags
FileExplorer
Asked by
Robert
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Wild
Top achievements
Rank 1
Share this question
or