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

Disabling context menus depending upon file extension

4 Answers 57 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Paul M
Top achievements
Rank 1
Paul M asked on 19 Dec 2016, 08:56 PM

I am able to add custom context menus, determine which menu items have been selected and disable the ones I don't need.  I need to take one step further and disable specific menu items depending upon the extension of the file selected.

I am coding everything in the OnGridContextShown function but one thing I have not been able to identify is the value of the selected item in the grid.  if I can get this, I can determine whether to disable a menu item or not.

Any suggestions?

Thanks

function OnGridContextShown(sender, args) {
    // How do I get the file name of the selected item?
    var treeContextMenuItems = sender.get_allItems();
    for (var i = 0; i < treeContextMenuItems.length; i++) {
        var menuItem = treeContextMenuItems[i];
        if (menuItem.get_value() == "Extract" || menuItem.get_value() == "Upload") {
            if (menuItem.get_value() == "Upload") {
                menuItem.disable(); // Disable the extract and upload function
            }
        }
    }
}

4 Answers, 1 is accepted

Sort by
0
Paul M
Top achievements
Rank 1
answered on 19 Dec 2016, 09:00 PM

Ignore the second if statement 9if (menuItem.get_value() == "Upload") {).  I was formatting the code to paste into here and lost the comment formatter.

function OnGridContextShown(sender, args) {
    // How do I get the file name of the selected item?
    var treeContextMenuItems = sender.get_allItems();
    for (var i = 0; i < treeContextMenuItems.length; i++) {
        var menuItem = treeContextMenuItems[i];
        if (menuItem.get_value() == "Extract" || menuItem.get_value() == "Upload") {
            menuItem.disable(); // Disable the extract and upload function
        }
    }
}

0
Accepted
Vessy
Telerik team
answered on 20 Dec 2016, 08:14 AM
Hi Paul,

You can get the name of the selected item through the RadFileExplorer client-side API like follows:
var selectedItemName = $find("RadFileExplorer1").get_selectedItem().get_name();

Regards,
Vessy
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Paul M
Top achievements
Rank 1
answered on 20 Dec 2016, 04:55 PM
Excellent, Vessy.  That was exactly the thing I was looking for.  I had seen the client side programming page you provided the link to, but didn't know how to access those properties.  Thanks again!
0
Vessy
Telerik team
answered on 23 Dec 2016, 08:44 AM
Hi,

You are welcome, Paul - I am glad the proposed solution is working for you.

Regards,
Vessy
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
FileExplorer
Asked by
Paul M
Top achievements
Rank 1
Answers by
Paul M
Top achievements
Rank 1
Vessy
Telerik team
Share this question
or