[CLOSED] Select node on Treepanel with right click...

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] Select node on Treepanel with right click...

    How can I make the a treepanel node become selected by right clicking as well as left clicking?
    Last edited by Daniil; Sep 13, 2010 at 10:36 PM. Reason: [CLOSED]
  2. #2
    Hello!

    Please look at the example.
    There handling of 'contextmenu' is used to achieve this behavior.

    Example
    <%@ 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 runat="server">
        <title>Ext.NET Example</title>
        <ext:ResourcePlaceHolder runat="server" />
    
        <script type="text/javascript">
            Ext.onReady(function () {
                TreePanel1.getRootNode().cascade(function (node) {
                    node.on('contextmenu', TreePanel1.getSelectionModel().onNodeClick);
                })
            });    
        </script>
    
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:TreePanel ID="TreePanel1" runat="server" Height="300">
            <Root>
                <ext:TreeNode Text="Composers" Expanded="true">
                    <Nodes>
                        <ext:TreeNode Text="Beethoven" Expanded="true">
                            <Nodes>
                                <ext:TreeNode Text="Concertos" Expanded="true">
                                    <Nodes>
                                        <ext:TreeNode Text="Concert 1" />
                                        <ext:TreeNode Text="Concert 2" />
                                    </Nodes>
                                </ext:TreeNode>
                            </Nodes>
                        </ext:TreeNode>
                    </Nodes>
                </ext:TreeNode>
            </Root>
        </ext:TreePanel>
        </form>
    </body>
    </html>
    Last edited by geoffrey.mcgill; Sep 13, 2010 at 9:45 PM. Reason: code revision
  3. #3
    That didn't seem to work. Here is my code sample. I put your Ext.onReady code in the head of my page. The rest of the Treepanel is being built in code behind.

                                <ext:TreePanel
                                    ID="TreePanel1"
                                    runat="server"
                                    Width="250"
                                    RootVisible="False" 
                                    Layout="Fit" 
                                    ContextMenuID="MenuContext"
                                    TrackMouseOver="true" 
                                    Border="false"
                                    Padding="10">
                                </ext:TreePanel>
    
                                <ext:Menu runat="server" ID="MenuContext">
                                    <Items>
                                        <ext:MenuItem runat="server" Text="Text">
                                            <Listeners>
                                                <Click Handler="alert(#{TreePanel1}.getSelectionModel().getSelectedNode().text);"/>
                                            </Listeners>
                                        </ext:MenuItem>
                                    </Items>
                                </ext:Menu>
  4. #4
    Hi tjbishop,

    I just tested @Daniil code above and it appears to work correctly. Getting the selected node does return the .text value.
    Geoffrey McGill
    Founder
  5. #5
    Could I be adding my nodes wrong in the code behind? All other functionality seems to be working okay.
  6. #6
    Quote Originally Posted by tjbishop View Post
    Could I be adding my nodes wrong in the code behind?
    Yes, it is possible.
    Geoffrey McGill
    Founder
  7. #7
    Oh yeah, I am adding the nodes on Page_Load. Could it be an order of operations issue?

Similar Threads

  1. [CLOSED] [1.0] Treepanel click node problem with ie9
    By PoloTheMonk in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 13, 2012, 12:44 PM
  2. No Expanded on click treepanel node!
    By abis in forum 2.x Help
    Replies: 2
    Last Post: Aug 12, 2012, 5:22 AM
  3. Help! How to get the select node in treepanel?
    By cf981231 in forum 1.x Help
    Replies: 2
    Last Post: Jan 27, 2011, 7:30 AM
  4. [CLOSED] TreePanel state: re-select node after refresh
    By ljcorreia in forum 1.x Legacy Premium Help
    Replies: 9
    Last Post: Mar 24, 2010, 12:27 PM
  5. Right-click node select in TreePanel?
    By dbassett74 in forum 1.x Help
    Replies: 6
    Last Post: May 14, 2009, 12:17 PM

Tags for this Thread

Posting Permissions