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

View ContextMenu only on the parentnode

3 Answers 62 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Colince
Top achievements
Rank 1
Colince asked on 08 Jul 2013, 03:55 PM
Hi, 
I have an issue regarding the view of tne contextMenu in the RadTreeView. I would like to view the contextMenu only on the parentnode and not on the child node while right_clicking  the mouse.
Thank you for any help

<telerik:RadTreeView ID="rtvCatalog" runat="server" EnableDragAndDrop="True"
                     OnNodeDrop="rtvCatalog_HandleDrop" MultipleSelect="false"
                     EnableDragAndDropBetweenNodes="true"
                     OnClientNodeDropping="onNodeDropping"
                     OnClientMouseOver="onNodeMouseOver"
                     OnClientMouseOut="onNodeMouseOut"
                     AllowNodeEditing="true"
                     OnNodeEdit="rtvCatalog_NodeEdit"
                     CausesValidation="false" Width="100%"
                     OnContextMenuItemClick="onMenuItemClick">
    <ContextMenus>
        <telerik:RadTreeViewContextMenu ID="mnuGroup" runat="server">
            <Items>
                <telerik:RadMenuItem Text="Order ascending" Value="Ascending"
                                 ImageUrl="~/Images/Sort-ascend.png" runat="server">
                </telerik:RadMenuItem>
                <telerik:RadMenuItem Text="Order descending" Value="Descending"
                                 ImageUrl="~/Images/Sort-descend.png" runat="server">
                </telerik:RadMenuItem>
                <telerik:RadMenuItem Text="Copy group in" Value="Select">
                </telerik:RadMenuItem>
            </Items>
        </telerik:RadTreeViewContextMenu>
    </ContextMenus>
</telerik:RadTreeView>

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 09 Jul 2013, 06:51 AM
Hi Collince,

Try attaching the following JavaScript code in the OnClientContextMenuShowing client event of the RadTreeView. The ContextMenu will be shown for root level elements only.

JavaScript:
<script type="text/javascript">
    function onClientContextMenuShowing(sender, args) {
        if (args.get_node().get_level() != 0) {
            args.set_cancel(true);
        }
    }
</script>

Thanks,
Shinu.
0
Accepted
Kate
Telerik team
answered on 09 Jul 2013, 07:03 AM
Hi Colince,

To get the context menu appear only to specific nodes from the RadTreeView control you can use the EnableContextMenu property of the nodes and set it to false for the child nodes.

Regards,
Kate
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Colince
Top achievements
Rank 1
answered on 09 Jul 2013, 07:43 AM
Many thanks to all,
I  tried the javascript's function and it works very well.
Tags
TreeView
Asked by
Colince
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Kate
Telerik team
Colince
Top achievements
Rank 1
Share this question
or