Disabling context menus depending upon file extension

5 posts, 1 answers
  1. Paul M
    Paul M avatar
    9 posts
    Member since:
    Oct 2016

    Posted 19 Dec 2016 Link to this post

    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
                }
            }
        }
    }
  2. Paul M
    Paul M avatar
    9 posts
    Member since:
    Oct 2016

    Posted 19 Dec 2016 in reply to Paul M Link to this post

    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
            }
        }
    }

  3. Answer
    Vessy
    Admin
    Vessy avatar
    1582 posts

    Posted 20 Dec 2016 Link to this post

    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.
  4. Paul M
    Paul M avatar
    9 posts
    Member since:
    Oct 2016

    Posted 20 Dec 2016 in reply to Vessy Link to this post

    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!
  5. Vessy
    Admin
    Vessy avatar
    1582 posts

    Posted 23 Dec 2016 Link to this post

    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.
Back to Top