[CLOSED] How to set the focus for the tree node in page load?

  1. #1

    [CLOSED] How to set the focus for the tree node in page load?

    hi,

    How to set the focus for the tree node in page load?I want to the select the first node in the tree in page load.


  2. #2

    RE: [CLOSED] How to set the focus for the tree node in page load?

    Hi,

    At this moment there is one solution only, register node selection in Render listener of TreePanel (if you don't use any tree loaders)
    <Render Handler="this.getSelectionModel().select(this.getNodeById('1'));" Delay="20" />
    Advanced tree support will be included to the 1.0 version

    Here is test case
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" 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="Head2" runat="server">
        <title></title>
        
        <script runat="server">
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!Ext.IsAjaxRequest)
                {
                    this.BuildTree(TreePanel1.Root);
                }
            }
            
            private Coolite.Ext.Web.TreeNodeCollection BuildTree(Coolite.Ext.Web.TreeNodeCollection nodes)
            {
                if(nodes == null)
                {
                    nodes = new Coolite.Ext.Web.TreeNodeCollection();
                }
                
                Coolite.Ext.Web.TreeNode root = new Coolite.Ext.Web.TreeNode();
                root.Text = "Root";
                nodes.Add(root);
    
                string prefix = DateTime.Now.Second + "_";
                for (int i = 0; i < 10; i++)
                {
                    Coolite.Ext.Web.TreeNode node = new Coolite.Ext.Web.TreeNode();
                    node.Text = prefix + i;
                    node.NodeID = i.ToString();
                    root.Nodes.Add(node);
                }
    
                return nodes;
            }
        </script>
        
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ScriptManager ID="ScriptManager1" runat="server" ScriptMode="Debug" />
            
            <ext:TreePanel ID="TreePanel1" runat="server" 
                Icon="Anchor" 
                Title="Tree"
                AutoScroll="true" 
                Width="250" 
                Collapsed="False" 
                CollapseFirst="True" 
                HideParent="False"
                RootVisible="False" 
                BodyStyle="padding-left:10px">
                <Listeners>
                    <Render Handler="this.getSelectionModel().select(this.getNodeById('1'));" Delay="20" />
                </Listeners>
             </ext:TreePanel>
        </form>
    </body>
    </html>

Similar Threads

  1. [CLOSED] Set selected node on initial page load
    By jchau in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 16, 2012, 11:19 AM
  2. Replies: 16
    Last Post: Jul 19, 2011, 3:53 AM
  3. Replies: 2
    Last Post: Oct 29, 2010, 10:04 AM
  4. [CLOSED] Focus handling in tree when link is clicked in detail page
    By Etisbew in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Sep 17, 2009, 11:52 AM
  5. [CLOSED] How to deselect the focus for the tree node in page load?
    By Etisbew in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Sep 15, 2009, 10:02 AM

Posting Permissions