[CLOSED] Treepanel CheckedNodes NULL when checking them from code behind.

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Treepanel CheckedNodes NULL when checking them from code behind.

    Hi,

    I use the following code to check a Treepanel node from code behind (depending on value in the database...a = b)

    //Create Node
    Ext.Net.TreeNode treeNode = new Ext.Net.TreeNode
            {
                NodeID = cNodeID,
                Text = cText,
                Qtip = cQtip,
                Expanded = true,
                Checked = (a=b) ? ThreeStateBool.True : ThreeStateBool.False
            };
    This works fine. The nodes are perfectly checked on screen when necessary.

    When saving the form again without changing the checklist (so ..do nothing with the treepanel), the following code is failing (NULL):

    String[] aDebiteur = TreePanel1.CheckedNodes.Select(sn => sn.Text.Split(' ')[0]).ToArray();
    // -- > use Array aDebiteur to update table in database with checked values
    The CheckNodes method is NULL

    ..but. If I check or uncheck some nodes with the mouse. This problem is not existing anymore. Above code gives me the checked nodes and I can use the value to save in the database

    Any ideas ?

    Martin
    Last edited by Daniil; Apr 25, 2011 at 7:59 AM. Reason: [CLOSED]
  2. #2
    Hi,

    I have reproduce the issue using the sample below. The solution should be easy, we are investigating.

    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>
        
        <script runat="server">
            protected void NodeLoad(object sender, NodeLoadEventArgs e)
            {
                if (!string.IsNullOrEmpty(e.NodeID))
                {
                    for (int i = 6; i < 11; i++)
                    {
                        Ext.Net.TreeNode treeNode = new Ext.Net.TreeNode();
                        treeNode.Text = e.NodeID + i;
                        treeNode.NodeID = e.NodeID + i;
                        treeNode.Leaf = true;
                        treeNode.Checked = i % 2 == 0 ? ThreeStateBool.True : ThreeStateBool.False;
                        e.Nodes.Add(treeNode);
                    }
                }
            }
    
            protected void CheckedNodesCount(object sender, DirectEventArgs e)
            {
                X.Msg.Alert("CheckedNodes.Count", this.TreePanel1.CheckedNodes.Count).Show();
            }
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:TreePanel 
                ID="TreePanel1" 
                runat="server" 
                Title="Tree" 
                AutoHeight="true" >
                <Loader>
                    <ext:PageTreeLoader OnNodeLoad="NodeLoad" />
                </Loader>
                <Root>
                    <ext:AsyncTreeNode NodeID="0" Text="Root" />
                </Root>
            </ext:TreePanel> 
            <ext:Button runat="server" Text="CheckedNodes.Count" OnDirectClick="CheckedNodesCount" />
        </form>
    </body>
    </html>
  3. #3
    Hi Daniil,

    Any progress on this one ?

    Martin
  4. #4
    Hi,

    Try to add the following listeners to the tree
    <Append Handler="this.updateCheckSelection();" Buffer="500" />
    <Insert Handler="this.updateCheckSelection();" Buffer="500" />
  5. #5
    Quote Originally Posted by Vladimir View Post
    Hi,

    Try to add the following listeners to the tree
    <Append Handler="this.updateCheckSelection();" Buffer="500" />
    <Insert Handler="this.updateCheckSelection();" Buffer="500" />
    Works !

    Mark as solved..

    Is this a workaround ? Or the definite solution ?

    Martin
  6. #6
    It's rather a bug.

    We are going to include this one in SVN. We will notice you.
  7. #7
    Hi,

    Added to SVN
  8. #8
    Quote Originally Posted by Vladimir View Post
    Hi,

    Added to SVN
    Is it possible this issues had popped up again ?

    Experiencing again the problem that populated checkednodes from code-behind are not recognized as 'checked'. But when 'deselecting' and selecting them again. They are recognized ..

    Above Testcode from Daniil gives an error too..

    Any idea ?

    Martin
  9. #9
    Quote Originally Posted by CarWise View Post
    Above Testcode from Daniil gives an error too..
    Please clarify what are the steps to reproduce the problem using that example?
  10. #10
    I am also experiencing this problem with v1.3.

    I have solved by adding

    <DocumentReady Handler="#{TreePanel1}.updateCheckSelection();" Buffer="500" />
    to the resource manager.

    This works as i only add nodes in code behind in the page load section.
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] TreePanel CheckNodes Null when checking them from codebehind
    By gs_user in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jun 25, 2012, 6:28 PM
  2. [CLOSED] CheckedNodes disable checked
    By gs_user in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jun 21, 2012, 8:21 AM
  3. Replies: 0
    Last Post: Dec 01, 2011, 6:43 AM
  4. how C# treepanel CheckedNodes?
    By abis in forum 1.x Help
    Replies: 3
    Last Post: Dec 06, 2010, 12:18 PM
  5. Replies: 2
    Last Post: Jun 14, 2010, 2:47 PM

Posting Permissions