[CLOSED] TreePanel selection behaviour

  1. #1

    [CLOSED] TreePanel selection behaviour

    Test the sample below in 2.5 and 4.1

    Load the page.

    The 2.5 behaviour: The root node ("0") is selected (even if not visible) and thus the SelectedNodes property is not null, nor empty.
    4.1: The root node ("0") is not selected and thus the SelectedNodes property is null.

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
       <script type="text/javascript">
          function SelectNode(nodeID)
             var tree = Ext.getCmp("TestTreePanel");
             var node = tree.store.getNodeById(nodeID);
             if (node != undefined)
       <script runat="server">
          protected void Page_Load( object sender, EventArgs e )
          protected void TreeNodeChanged( object sender, DirectEventArgs e )
             VerifySelection( "TreeNodeChanged" );
          private void VerifySelection( string sMethodName )
             if ( TestTreePanel.SelectedNodes != null && TestTreePanel.SelectedNodes.Count > 0 )
                //get submitted node
                SubmittedNode nodeSubmitted = TestTreePanel.SelectedNodes.FirstOrDefault();
                if ( nodeSubmitted != null )
                   X.Msg.Alert( sMethodName, nodeSubmitted.NodeID ).Show();
                   X.Msg.Alert( sMethodName, "Null node" ).Show();
                X.Msg.Alert( sMethodName, TestTreePanel.SelectedNodes == null ? "Null selection" : "Empty selection" ).Show();
          protected void TreeNodeDblClick( object sender, DirectEventArgs e )
             VerifySelection( "TreeNodeDblClick" );
          private void SelectRootNode()
             TestTreePanel.SelectPath( "/0" );
          protected void NodeLoad( object sender, NodeLoadEventArgs e )
             if ( !String.IsNullOrEmpty( e.NodeID ) )
                if ( e.NodeID == "0" )
          protected void btnTest_DirectClick( object sender, Ext.Net.DirectEventArgs e )
             VerifySelection( "btnTest_DirectClick" );
       <form id="form1" runat="server">
          <ext:ResourceManager ID="rscManager" runat="server" />
          <ext:Button ID="btnTest" runat="server" Text="Test" OnDirectClick="btnTest_DirectClick" />
             Title="Test tree panel"
             RootVisible="false" Frame="true" Layout="FitLayout" Flex="1" DeferRowRender="False">
                <SelectionChange OnEvent="TreeNodeChanged"></SelectionChange>
                <ItemDblClick OnEvent="TreeNodeDblClick"></ItemDblClick>
                <ext:TreeStore ID="TariffTreeStore" runat="server" OnReadData="NodeLoad">
                      <ext:PageProxy />
                      <ext:Model ID="Model1" runat="server">
                            <ext:ModelField Name="NodeType" />
                      <ext:StoreParameter Name="ID" Value="2" Mode="Raw" />
                <ext:Node NodeID="0" Text="Root" Expanded="true" />
                <ext:TreeSelectionModel runat="server" ID="treeSelectionModel" AllowDeselect="True"></ext:TreeSelectionModel>
    Last edited by fabricio.murta; Sep 16, 2016 at 12:50 AM.
  2. #2
    Hello Edgar!

    Thanks your example is paste-and-run! We really appreciate this so we can understand what's happening.

    But at a first thought, it seems to me that it makes sense, and invisible root node not being selectable at all. In fact, I can't select it even if I set the selectionModel's SelectedRows to select it (as long as the RootVisible is false).

    I can understand it as a breaking change between the two versions, but I'm just wondering in which situation you would need the hidden root entry to be selectable. As being hidden, does not make much sense to me. But maybe in the simplified test case you provided it does not make sense.

    I could rather expect a bugfix changed the treePanel so that it does not select the root node by default, which usually is a dummy entrypoint for other nodes (when it is hidden, that is).

    Anyway, if we understand better your need on having it selected, we could try to suggest you one or two solutions, just not sure is this what you really want.
    Fabrício Murta
    Developer & Support Expert
  3. #3
    OK Fabrício. I thought I was perhaps missing a setting or something. The code-behind was built based on the 2.5 behaviour (i.e. non-null SelectedNodes property). This is a minor thing to fix, so there's no need for a solution.

    Many thanks!
  4. #4
    Glad it works out for you! Thanks for the feedback!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Replies: 2
    Last Post: Jan 29, 2016, 9:19 PM
  2. TreePanel selection model
    By joris.moonen in forum 2.x Help
    Replies: 1
    Last Post: Nov 12, 2015, 3:45 PM
  3. TreePanel expand node behaviour
    By web4u in forum 2.x Help
    Replies: 1
    Last Post: Aug 28, 2012, 1:02 PM
  4. Problem with TreePanel Selection[1.0]
    By suchit_patel in forum 1.x Help
    Replies: 0
    Last Post: Jul 21, 2010, 8:38 AM
  5. TreePanel Selection
    By erey in forum 1.x Help
    Replies: 0
    Last Post: Jul 02, 2009, 4:12 PM

Tags for this Thread

Posting Permissions