According to https://docs.telerik.com/kendo-ui/controls/data-management/filemanager/context-menu:
You can define your custom items which can execute custom commands
However, no option allows me to configure my own commands.
I managed to hack this: https://dojo.telerik.com/@GaloisGirl/iLoHIhoh , but it's an ugly solution.
Hello Anna,
The Command class will be changed, it will be part of the FileManager implementation and it will be exposed through the kendo.ui.filemanager namespace. That way you will be able to reuse it and create a custom Command that will inherit that base class. Without the need to copy the code like know.
The click handler mentioned comes from the Toolbar that is a composite widget and it is not capable of providing FileManager-specific data. I understand that it seams easier to handle with a single click handler and it is when it comes to a simple action that consists of one or two lines of code. For complex commands, it will be harder to handle within a single function. Also, the Toolbar as a composite widget is reused in multiple other components (Spreadsheet, PDFViewer and so on). Having the same click handler handling and dispatching data for every specific widget would make the code hard to maintain.
This is why using Command classes that are FileManager-specific and are part of the FileManager code base is a better option. That way you will have a base class to extend and rely that the basic functionalities (like options handling and initialization) will be already handled. And the only part to handle is command-specific functionalities. Plus, the ability to have a much more complex command.
On a side note, the solution with the handler is available in the Kendo Editor. With time it is proven that this solution works as a great way to step into custom commands. But once, the command gets more complex command classes were needed and implemented. And those exposed to the developers so that they can reuse them.
Regards,
Ianko
Progress Telerik
Hi Ianko,
In my solution, I had to copy the definition of the Command class. That means with every new Kendo release, I'll have to check if that definition hasn't changed. I need that class exported and available for inheritance.
Ideally, I would be to just be able to define a handler, like I can to for toolbar commands, for instance this refresh button: https://dojo.telerik.com/@GaloisGirl/OJUPoYOY
It would be great if the dataItem could be readily passed to the handler. My logic to find the dataItem was copied (that word is a big red flag) from the RenameCommand, and again, it relies on internal working of the FileManager widget, which can change in the future.
Maybe the method executeCommand could fail silently if the command is not found (it now throws "TypeError: n.filemanager.commands[t] is not a constructor"), trigger the EXECUTE event, and I could also place my logic here.
Hi Anna,
Actually, this is the exact way to create a custom command for either the contextmenu or the toolbar. And we have plans to create a documentation article with a command that looks very similar to how you have implemented it.
Can you provide some more details how would you expect to create a custom command if that option seams like a hack to you?
Regards,
Ianko
Progress Telerik