[CLOSED] Context Menu in the Tree panel

  1. #1

    [CLOSED] Context Menu in the Tree panel

    Hi

    I have a tree panel which loads all the data to construct a tree.
    I even have a Menu with two MenuItem, the first MenuItem is to create an child node under the selected node,
    the second MenuItem is to Delete a node under the selected node, i use 'ContextMenuID= menuID' attribute of treepanel
    On selection of any node i need to get both the menuitem execept at the root node i need to show only First MenuItem.
    As i do not want to delete the root node.

    Thank you.
  2. #2
    Hi the code is as below.

    <ext:Menu runat="server" ShowSeparator="true" ID="CompanyMenu">
        <Items>
            <ext:MenuItem ID="mnuCreate" runat="server" Text="Create Child Company" Icon="BulletHome"/>
            <ext:MenuItem ID="mnuDelete" runat="server" Text="Delete Company" Icon="Cross" />
        </Items>
    </ext:Menu>
    <ext:TreePanel Height="600" Layout="Fit" ID="TreePanel1" Lines="true" runat="server" 
        Frame="false" UseArrows="false" AutoScroll="true" Animate="true" EnableDD="true" CollapseFirst="false" 
        ContainerScroll="true" Border="false" RootVisible="false" AutoDataBind="true" IDMode="Explicit" 
        ContextMenuID="CompanyMenu" AutoDestroy="true">
    </ext:TreePanel>
  3. #3
    Please see the following post how to create context menuy for tree panel
    http://forums.ext.net/showthread.php...ull=1#post6344
  4. #4
    Hi i dont know what u r trying to do with
    ext:TextMenuItem
    i get error, it says there is nothing called 'ext:TextMenuItem'

    as told in the previous post i can create a contextmenu, but i dont want to show the second menu only in the root node(ie, first node)
  5. #5
    1. Use MenuTextItem (if such item is required)

    2.
    as told in the previous post i can create a contextmenu, but i dont want to show the second menu only in the root node(ie, first node)
    Analyze node and show/hide menu's items

    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title></title>
        
        <style type="text/css">
            .node-label
            {
                font-weight:bold;
                font-size:12px;
                padding:5px 0px 5px 28px;            
                width:150px;
            }
        </style>
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ResourceManager runat="server" />
        
            <ext:TreePanel ID="Browse" runat="server">
                <Root>
                    <ext:TreeNode Text="Home" Leaf="false" Icon="House">
                        <Nodes>
                            <ext:TreeNode Text="Folder 1" Icon="Folder">
                                <Nodes>
                                    <ext:TreeNode Text="File 1" Icon="Folder" />
                                </Nodes>
                            </ext:TreeNode>
                            <ext:TreeNode Text="Folder 2" Icon="Folder">
                                <Nodes>
                                    <ext:TreeNode Text="File 2" Icon="Share" />
                                </Nodes>
                            </ext:TreeNode>
                        </Nodes>
                    </ext:TreeNode>
                </Root>
                <Listeners>
                    <ContextMenu Handler="#{BrowseMenu}.node = node;#{BrowseMenu}.showAt(e.getXY());" />
                </Listeners>
            </ext:TreePanel>
             
            <ext:Menu ID="BrowseMenu" runat="server">
                <Items>
                    <ext:MenuTextItem ID="NodeLabel" runat="server" CtCls="node-label"  />
                    <ext:MenuItem ID="Item1" Text="Create" >                   
                    </ext:MenuItem>
                    <ext:MenuItem ID="Item2" Text="Delete" >                   
                    </ext:MenuItem>
                </Items>
                <Listeners>
                    <BeforeShow Handler="#{NodeLabel}.setText(this.node.text); #{Item2}.setVisible(!this.node.isRoot);" />
                </Listeners>
            </ext:Menu>
        </form>
    </body>
    </html>
  6. #6
    Thank you it helped me.

Similar Threads

  1. Replies: 0
    Last Post: Mar 29, 2012, 12:50 PM
  2. Replies: 1
    Last Post: Feb 17, 2012, 12:38 PM
  3. [CLOSED] Context Menu in the tree is not seen, it shows the shadow
    By Shanth in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Nov 21, 2011, 2:05 PM
  4. Context menu on tree grid
    By Mr.Techno in forum 1.x Help
    Replies: 20
    Last Post: Nov 17, 2011, 10:18 AM
  5. [CLOSED] Tab Panel Context Menu
    By skyone in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 12, 2011, 4:56 PM

Posting Permissions