Detecting if Grid row is a file or a folder

3 posts, 0 answers
  1. lordscarlet
    lordscarlet avatar
    19 posts
    Member since:
    Jan 2007

    Posted 06 Apr 2011 Link to this post

    I am trying to complete a task that I have found half the answer for. I would like the context menu in the grid to only work on files, not folders. I found the solution for hiding the context menu. However, I'm not sure how to check each row for whether it is a file or folder. I am digging through the javascript now, but this is time sensitive so I thought I would post right away.
  2. lordscarlet
    lordscarlet avatar
    19 posts
    Member since:
    Jan 2007

    Posted 06 Apr 2011 Link to this post

    I found a solution. I would appreciate knowing if there is a better one, but for the short term, this one works.

    function OnGridContextShowing(oMenu, args) {
        if ($(args.get_targetElement()).attr('class').indexOf("folder") >= 0)
            args.set_cancel(true);
    }
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 07 Apr 2011 Link to this post

    Hi Doug,

    The approach that you have used is OK and actually, it will handle cases where the right click occurs on an empty grid row or header row, and I will recommend using it.

    Another possible approach is to examine the explorer's selected item, e.g.:
    .....
    var selectedItem = explorer.get_grid().get_selectedItems()[0];
    if(selectedItem && selectedItem.isDirectory())
        args.set_cancel(true);
     
    .....


    Kind regards,
    Dobromir
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top