context Menu according to the node

2 posts, 1 answers
  1. David
    David avatar
    81 posts
    Member since:
    May 2011

    Posted 18 Aug 2011 Link to this post

    Hi,

    is it possible to show a contextMenu with different items according to the item clicked. By example, for this treeView :

        LevelA1
        LevelA2
            Level2A
            Level2B
        LevelA3

    Level2A et Level2B will have a context menu that show "Edit" and LevelA1-A2 will show "ADD" and LevelA3 will show "Delete". 

    Thank you.
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 19 Aug 2011 Link to this post

    Hello David,

    You can achieve this by specifying RadTreeViewContextMenu ID for each node as shown below.

    aspx:
    <telerik:RadTreeView runat="server" ID="RadTreeView3">
      <ContextMenus>
          <telerik:RadTreeViewContextMenu ID="RadTreeViewContextMenu2">
               <Items>
                    <telerik:RadMenuItem Text="Edit" />
                     <telerik:RadMenuItem Text="Send" />
                     <telerik:RadMenuItem Text="Email" />
               </Items>
          </telerik:RadTreeViewContextMenu>
          <telerik:RadTreeViewContextMenu ID="RadTreeViewContextMenu1">
             <Items>
                  <telerik:RadMenuItem Text="Edit" />
             </Items>
          </telerik:RadTreeViewContextMenu>
     </ContextMenus>
         <Nodes>
         <telerik:RadTreeNode Text="LevelA3">
        <Nodes>
          <telerik:RadTreeNode Text="Path" Value="1" ContextMenuID="RadTreeViewContextMenu2" />                   
       </Nodes>
         </telerik:RadTreeNode>
         </Nodes>
        <Nodes>
         <telerik:RadTreeNode Text="Level2A">
              <Nodes>
               <telerik:RadTreeNode Text="Inbox" Value="1" ContextMenuID="RadTreeViewContextMenu1" />
                </telerik:RadTreeNode>
               </Nodes>
         </telerik:RadTreeNode>
       </Nodes>
    </telerik:RadTreeView>

    Thanks,
    Princy.
Back to Top