I see that when doing a copy a Create call is executed and when doing a move it executes Create and Destroy. Is there a way to detect when a copy was done vs a move? When doing a move, I actually need to do a move in the back end so a Create and Destroy does not work for me.
Thanks,
6 Answers, 1 is accepted
I found that I can override the MoveCommand as below and it works for my scenario.
filemanagerNS.commands.MoveCommand = filemanagerNS.FileManagerCommand.extend({
exec: function () {
var that = this,
filemanager = that.filemanager, // get the kendo.ui.FileManager instance
options = that.options, // get the options passed through the tool
target = options.target // options.target is available only when command is executed from the context menu
selectedFiles = filemanager.getSelected(); // get the selected files
//My move logic here
}
});
Hello Carlos,
Thank you for sharing your solution. It could be helpful for someone else in the community in the future.
If it is suitable for your scenario, you could subscribe to the execute event of the FileManager. In the event handler, you could check if the 'Move' or 'Copy' action is selected by checking the "e.command" as in the example below:
function onExecute(e) {
kendoConsole.log("event: Execute --> " + e.command);
}
Here is a small Dojo example where the type of the selected command is logged in a Kendo Console.
Regards,
Neli
Progress Telerik
Hi Neli,
Thanks for the follow up. I did try that, but I didn't find a way to cancel the command so it was executing the default Move/Copy calls after executing my custom call. Is there a way cancel command from the Execute event?
Hi Carlos,
If you need to cancel a command in the execute event handler of the FileManager widget you could use the preventDefault() method and prevent the default behavior.
In the example below the "Move" of the items will be canceled in case the name of the item contains the string "demos":
function onExecute(e) {
var items = e.options.items;
var hasDemos = items.some(function(v) {
return v.includes("demos");
})
kendoConsole.log("event: Execute --> " + e.command);
if(e.command == "MoveCommand" && hasDemos == true){
e.preventDefault()
alert("Canceled!!!")
}
}
Here is a Dojo example where the implementation provided above is used.
I hope the provided information will be helpful.
Regards,
Neli
Progress Telerik