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

How to prevent folders from being deleted/renamed

2 Answers 60 Views
FileManager
This is a migrated thread and some comments may be shown as answers.
Responsive
Top achievements
Rank 1
Veteran
Responsive asked on 25 Jan 2021, 10:17 PM
I would like my users to be able to renamed or delete files, but not folders. I found the post asking how to prevent subfolders from being created, but delete and renaming seem to be different animals.

2 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Danchev
Telerik team
answered on 27 Jan 2021, 04:59 PM

Hello,

You can achieve that with conditional logic in the FileManager's "Execute" event handler:

1. Attach an "Execute" event handler.
2. In the handler check the name of the command and whether the selected item is a folder. If the conditions are fulfilled, prevent the event:

function onExecute(e) {
	if (e.command == "DeleteCommand" || e.command == "RenameCommand") {
            if (e.sender.getSelected()[0].isDirectory) {
                e.preventDefault();
            }
	}
}

Regards,
Ivan Danchev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Responsive
Top achievements
Rank 1
Veteran
answered on 28 Jan 2021, 08:05 PM
Worked like a charm. Thanks.
Tags
FileManager
Asked by
Responsive
Top achievements
Rank 1
Veteran
Answers by
Ivan Danchev
Telerik team
Responsive
Top achievements
Rank 1
Veteran
Share this question
or