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

  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

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

    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    <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);
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:TreePanel ID="TreePanel1" runat="server" Height="300">
                <ext:TreeNode Text="Composers" Expanded="true">
                        <ext:TreeNode Text="Beethoven" Expanded="true">
                                <ext:TreeNode Text="Concertos" Expanded="true">
                                        <ext:TreeNode Text="Concert 1" />
                                        <ext:TreeNode Text="Concert 2" />
    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:Menu runat="server" ID="MenuContext">
                                        <ext:MenuItem runat="server" Text="Text">
                                                <Click Handler="alert(#{TreePanel1}.getSelectionModel().getSelectedNode().text);"/>
  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 & CEO
  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 & CEO
  7. #7
    Oh yeah, I am adding the nodes on Page_Load. Could it be an order of operations issue?
  8. #8
    It seems that it was an order of operations issue. I used X.AddScript to execute the javascript after I loaded my treepanel...

    X.AddScript("TreePanel1.getRootNode().cascade(function (node) {" + 
    "node.on('contextmenu', TreePanel1.getSelectionModel().onNodeClick);" +
    Thanks for you help! You can mark as solved.

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