EXT.NET 3.0.0 RELEASED!
Now with Tablet Support!
Ext.NET 3.0.0 is here with lots of new cool features and now with tablet support! Check Examples Explorer now to see it in action or download and test it yourself for free!
Results 1 to 5 of 5

Thread: [CLOSED] TreePanel + Listeners + Click/BeforeClick

  1. #1
    Premium Member
    Join Date
    Feb 2009
    Posts
    364

    [CLOSED] TreePanel + Listeners + Click/BeforeClick

    I noticing that Click and BeforeClick on the TreePanel have the same behavior. I don't know if this is an ExtJS problem or a Coolite problem.

    Here is some code to demonostrate the problem. Here is the .aspx page:

    Code:
    <script language="javascript" type="text/javascript">
    var PanelEvents = {
    getSelectModel: function(panelName)
    {
      try {
        var panel = Ext.getCmp(panelName);
    
        alert(panel.selModel.getSelectedNode().id);
        } catch(err) {
          Ext.Msg.alert('Javascript Error', err.description);
        }
      }
    }
    </script>
    
    <ext:TreePanel ID="tpPanel" runat="server" AutoScroll="true" Border="false" RootVisible="false" IDMode="Static">
      <Loader>
        <ext:PageTreeLoader OnNodeLoad="tpPanel_NodeLoad" />
      </Loader>
      <Listeners>
        <Click Handler="PanelEvents.getSelectModel('tpPanel');" />
      </Listeners>
    </ext:TreePanel>
    Here is the code behind:

    Code:
    protected void Page_Load(object sender, EventArgs e)
    {
      if (!this.IsPostBack &amp;&amp; !Ext.IsAjaxRequest)
      {
        this.BuildUsersTree();
      }
    }
    
    protected void tpPanel_NodeLoad(object sender, NodeLoadEventArgs e) 
    {
      if (!string.IsNullOrEmpty(e.NodeID))
      {
      // Do some stuff here
      }
      }
    
      private void BuildUsersTree()
      {
      IntUsers.Users user = new IntUsers.Users(this.ConnectionString);
      DataTable users = user.GetUsers();
    
      TreeNode nodeUsers = new TreeNode("Users", Icon.Group);
      tpPanel.Users.Add(nodeUsers);
    
      if (users != null &amp;&amp; users.Rows.Count > 0)
      {
      foreach(DataRow data in users.Rows)
      {
      string fullName = Convert.ToString(data["FullName"]);
      string userId = Convert.ToString(data["UserId"]);
      bool isOnline = Convert.ToBoolean(data["IsOnline"]);
    
      Icon statusIcon = (isOnline) ? Icon.StatusOnline : Icon.StatusOffline;
    
      AsyncTreeNode userNode = new AsyncTreeNode("ur" + userId, fullName);
      userNode.Icon = statusIcon;
    
      nodeUsers.Nodes.add(userNode);
      }
      }
    }
    Now, the problem is that the selectedNode() isn't available on the Click listener at this point. It's excibiting the same behavior as a BeforeClick listener.

    If I fire the Click listener event, then I how am I suppose to get the currently selected node (or it's id)?

    Thanks.

  2. #2
    Premium Member
    Join Date
    Feb 2009
    Posts
    364

    RE: [CLOSED] TreePanel + Listeners + Click/BeforeClick

    By the way, I do know about passing "node" from the call to the function.

    However, we are using this in various ways (other than just a call from Click) and we need to pull the selectionModel instead of the node.


    Thanks.



  3. #3
    Ext.NET - Dev Team geoffrey.mcgill's Avatar
    Join Date
    Jan 2008
    Location
    Canada
    Posts
    8,699

    RE: [CLOSED] TreePanel + Listeners + Click/BeforeClick

    Hi state,

    The first parameter sent to the .Handler for both <BeforeClick> and <Click> is an instance of the 'node'.

    Example

    Code:
    <%@ 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="Head1" runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ScriptManager runat="server" />
            <ext:TreePanel ID="TreePanel1" runat="server" Height="300" Width="185" Title="Tree">
                <Root>
                    <ext:TreeNode Text="Item1" Expanded="true">
                        <Nodes>
                            <ext:TreeNode Text="Item2" />
                            <ext:TreeNode Text="Item3" />
                        </Nodes>
                    </ext:TreeNode>
                </Root>
                <Listeners>
                    <BeforeClick Handler="console.log('BeforeClick', node);" />
                    <Click Handler="console.log('Click', node);" />
                </Listeners>
            </ext:TreePanel>
        </form>
    </body>
    </html>
    Hope this helps.

    Geoffrey McGill
    Ext.NET, Inc.
    Founder, and Dev Team

    Ext.NET Examples | Ext.NET API Docs | ExtJS API Docs | @extnet | Jobs

  4. #4
    Premium Member
    Join Date
    Feb 2009
    Posts
    364

    RE: [CLOSED] TreePanel + Listeners + Click/BeforeClick



    I don't know if Coolite supports a multiple select model in the TreePanel.

    So, how would this be handled in that case? Does the Click/BeforeClick pass back an array of selected nodes?

  5. #5
    Ext.NET - Dev Team geoffrey.mcgill's Avatar
    Join Date
    Jan 2008
    Location
    Canada
    Posts
    8,699

    RE: [CLOSED] TreePanel + Listeners + Click/BeforeClick

    There is MultiSelectionModel functionality, but we have yet to implemented this server-side.

    The following sample demonstrates how you can manually configure the MultiSelectionModel.

    Example

    Code:
    <ext:TreePanel ID="TreePanel1" runat="server" Height="300" Width="185" Title="Tree">
        <Root>
            <ext:TreeNode Text="Item1" Expanded="true">
                <Nodes>
                    <ext:TreeNode Text="Item2" />
                    <ext:TreeNode Text="Item3" />
                </Nodes>
            </ext:TreeNode>
        </Root>
        <CustomConfig>
            <ext:ConfigItem Name="selModel" Value="new Ext.tree.MultiSelectionModel()" Mode="Raw" />
        </CustomConfig>
        <Listeners>
            <BeforeClick Handler="console.log('BeforeClick', node);" />
            <Click Handler="console.log('Click', node);" />
        </Listeners>
    </ext:TreePanel>
    The BeforeClick and Click events are fired when each node is clicked (selected).


    Geoffrey McGill
    Ext.NET, Inc.
    Founder, and Dev Team

    Ext.NET Examples | Ext.NET API Docs | ExtJS API Docs | @extnet | Jobs

Similar Threads

  1. illegal XML character, TreePanel Listeners ?
    By Mohammad in forum 1.x Help
    Replies: 3
    Last Post: Nov 20, 2011, 5:32 AM
  2. Click Listeners for HyperLink, ext.net ?
    By Mohammad in forum 1.x Help
    Replies: 4
    Last Post: Oct 23, 2011, 8:03 AM
  3. Replies: 4
    Last Post: Aug 23, 2011, 4:03 PM
  4. Q: Button Listeners.Click Question
    By bruce in forum 1.x Help
    Replies: 1
    Last Post: Mar 17, 2009, 3:31 AM
  5. TreePanel SelectionModel Listeners
    By jchau in forum 1.x Premium Help
    Replies: 2
    Last Post: Dec 19, 2008, 4:47 PM

Posting Permissions