[CLOSED] Problems with TreePanel ClearChecked

  1. #1

    [CLOSED] Problems with TreePanel ClearChecked

    Last edited by Daniil; Jan 13, 2014 at 10:56 AM. Reason: [CLOSED]
  2. #2
    Hi @MarcA,

    You can do it this way:
    treePanel.GetNodeById("R0").SetChecked(true);
    treePanel.GetNodeById("R1").SetChecked(true);
  3. #3
    Thank you for your quick response.

    1). When I clear the checkbox treePanel.ClearChecked(), all my nodes get checkboxes also if they did not have a checkbox.
    how can i clear all the nodes that have a checkbox at once?
    2). How do I remove the Icons?
    3). I have set
     RowLines = false
    on the TreePanel but i still see lines.
    How do I remove them?

    using treePanel.GetNodeById works, is there a way I can check if the node exists before setting?


    Marc


    Quote Originally Posted by Daniil View Post
    Hi @MarcA,

    You can do it this way:
    treePanel.GetNodeById("R0").SetChecked(true);
    treePanel.GetNodeById("R1").SetChecked(true);
  4. #4
    Quote Originally Posted by MarcA View Post
    1). When I clear the checkbox treePanel.ClearChecked(), all my nodes get checkboxes also if they did not have a checkbox.
    how can i clear all the nodes that have a checkbox at once?
    I see. Please try this override:
    Ext.tree.Panel.override({
        toggleChecked : function (startNode, value) {
            startNode = startNode || this.getRootNode();       
     
            var f = function (node) {
                var oldValue = node.get("checked");
                        
                if (oldValue !== null && oldValue !== value) {
                    node.set('checked', value);
                    this.fireEvent('checkchange', node, value);
                }
            };
            
            var originFn = this.updateCheckSelection;
            this.updateCheckSelection = Ext.emptyFn;
    
            startNode.cascadeBy(f, this);
    
            this.updateCheckSelection = originFn;
            this.updateCheckSelection();
        }
    });


    Quote Originally Posted by MarcA View Post
    2). How do I remove the Icons?
    I am not 100% sure what you mean. Please clarify.

    Quote Originally Posted by MarcA View Post
    3). I have set
     RowLines = false
    on the TreePanel but i still see lines.
    How do I remove them?
    Please start a new forum thread.

    Quote Originally Posted by MarcA View Post
    using treePanel.GetNodeById works, is there a way I can check if the node exists before setting?
    Please start a new forum thread.
  5. #5
    Quote Originally Posted by Daniil View Post
    I see. Please try this override:
    Ext.tree.Panel.override({
        toggleChecked : function (startNode, value) {
            startNode = startNode || this.getRootNode();       
     
            var f = function (node) {
                var oldValue = node.get("checked");
                        
                if (oldValue !== null && oldValue !== value) {
                    node.set('checked', value);
                    this.fireEvent('checkchange', node, value);
                }
            };
            
            var originFn = this.updateCheckSelection;
            this.updateCheckSelection = Ext.emptyFn;
    
            startNode.cascadeBy(f, this);
    
            this.updateCheckSelection = originFn;
            this.updateCheckSelection();
        }
    });
    Finally, we considered it as a bug and fixed in the SVN trunk, revision #5599.

    Also we added the SetAllChecked method for TreePanel. It is an opposite of ClearChecked.

    So, with that last SVN revision this example is going to work.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void ClearChecked(object sender, DirectEventArgs e)
        {
            this.TreePanel1.ClearChecked();
        }
    
        protected void SetAllChecked(object sender, DirectEventArgs e)
        {
            this.TreePanel1.SetAllChecked();
        }
    </script>
    
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:TreePanel ID="TreePanel1" runat="server">
                <Root>
                    <ext:Node Text="Root (level 0)" Expanded="true">
                        <Children>
                            <ext:Node Text="Node1 (level 1)" Expanded="true">
                                <Children>
                                    <ext:Node Text="Node1 (level 2)" Expanded="true">
                                        <Children>
                                            <ext:Node Text="Node1 (level 3)" Leaf="true" Checked="true" />
                                            <ext:Node Text="Node2 (level 3)" Leaf="true" />
                                        </Children>
                                    </ext:Node>
                                </Children>
                            </ext:Node>
                            <ext:Node Text="Node2 (level 1)" Expanded="true">
                                <Children>
                                    <ext:Node Text="Node1 (level 2)" Expanded="true" Checked="true">
                                        <Children>
                                            <ext:Node Text="Node1 (level 3)" Leaf="true" />
                                            <ext:Node Text="Node2 (level 3)" Leaf="true" />
                                        </Children>
                                    </ext:Node>
                                </Children>
                            </ext:Node>
                        </Children>
                    </ext:Node>
                </Root>
            </ext:TreePanel>
    
            <ext:Button runat="server" Text="Clear checked" OnDirectClick="ClearChecked" />
    
            <ext:Button runat="server" Text="SetAllChecked" OnDirectClick="SetAllChecked" />
        </form>
    </body>
    </html>
  6. #6
    Thank you,

    Using the overide works.

    Marc

Similar Threads

  1. TreePanel have in 2.2 Format Problems
    By KevinWinter in forum 2.x Help
    Replies: 0
    Last Post: May 30, 2013, 10:27 AM
  2. [CLOSED] Treepanel ClearChecked method
    By mirwais in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Nov 27, 2012, 2:39 AM
  3. Replies: 8
    Last Post: Apr 04, 2012, 11:13 PM
  4. [CLOSED] Treepanel IE9 problems
    By ewgoforth in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: May 12, 2011, 2:38 PM
  5. TreePanel problems
    By artiscodex in forum 1.x Help
    Replies: 3
    Last Post: Nov 29, 2010, 5:25 PM

Tags for this Thread

Posting Permissions