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

Detecting if Grid row is a file or a folder

2 Answers 69 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
lordscarlet
Top achievements
Rank 1
lordscarlet asked on 06 Apr 2011, 10:22 PM
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 Answers, 1 is accepted

Sort by
0
lordscarlet
Top achievements
Rank 1
answered on 06 Apr 2011, 10:33 PM
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);
}
0
Dobromir
Telerik team
answered on 07 Apr 2011, 12:21 PM
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
Tags
FileExplorer
Asked by
lordscarlet
Top achievements
Rank 1
Answers by
lordscarlet
Top achievements
Rank 1
Dobromir
Telerik team
Share this question
or