|
Rank: Newbie Groups: Member
Joined: 11/23/2007 Posts: 3
|
Hi,
I have a TreeView with nesting items. The thing is, some of these items are just "folders" and not an actual item. I would like it so when a user right-clicks an "Item", eo_ShowContextMenu is called to display the menu. But if the user clicks a "Folder", eo_ShowContextMenu isn't called and no menu is displayed.
How can I accomplish this? Is there a "type" or something I can use to define what the node is (Item or Folder)?
Thanks in advance.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi Jonathan, There isn't a type on NavigationItem but you can check the number of child item it has. Use the following code:
Code: JavaScript
var item = e.getItem();
if (item.getSubGroup() && item.getSubGroup().getItemCount())
{
//this is a "folder"....
}
else
{
//this is an "item"....
}
Thanks
|
|
Rank: Newbie Groups: Member
Joined: 11/23/2007 Posts: 3
|
Hi,
Thanks for the quick reply.
Unfortunately, I can't get it to work.
<script type="text/javascript"> function ShowContextMenu(e, treeView, node) { var item = e.getItem(); alert(item.getSubGroup()); alert(item.getSubGroup().getItemCount()); } </script>
I tried the above and it doesn't popup anything.
Also, I see javascript errors "Use of captureEvents() and releaseEvents() is deprecated, see bug 330494" whenever I click NavigationItems.
Any ideas?
Thanks in advance.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Oh. I thought you were using ClientSideOnItemClick. In your case you would just do node.getSubGroup() and node.getSubGroup().getItemCount() because here node is a NavigationItem object.
node.getSubGroup() returns an NavigationItemGroup object. So you won't be able to see anything when you alert it. However you should be able to see a number when you do alert(node.getSubGroup().getItemCount()).
You don't need to worry about the "Use of captureEvents() and releaseEvents() is deprecated, see bug 330494". That's an annoying FireFox message that doesn't really cause any problem with our TreeView.
Thanks
|
|
Rank: Newbie Groups: Member
Joined: 11/23/2007 Posts: 3
|
Worked like a charm! Thanks!
|
|