Check child nodes treepanel

  1. #1

    Check child nodes treepanel

    Hi, i need help for Check child nodes in treepanel. I have a problem for check child nodes. i already try this http://forums.ext.net/showthread.php...ll=1#post95193

    And i got this error Click image for larger version. 

Name:	errorrrrrr1.JPG 
Views:	18 
Size:	21.1 KB 
ID:	7376

    var onCheckChange = function (node, checked) {
            if (!this.locked) {
            this.locked = true;
       
            if (node.hasChildNodes()) { 
                node.cascade(function (childNode) {
                    childNode.set("checked", checked);
                });      
            }
     
            var nodoPadre = node.parentNode; 
                if (nodoPadre != null) {
                    if (checked == false) { 
                        nodoPadre.set("checked", false);
                        var nodoPadre2 = nodoPadre.parentNode;
                        if (nodoPadre2 != null) {
                            nodoPadre2.set("checked", false);
                        }
                    } else{
                        var todosCheck = true;
                        nodoPadre.cascade(function (childNode2) {
                            if ((childNode2.data.checked == false) && (nodoPadre.data.text != childNode2.data.text)) {todosCheck = false; }
                        });   
                        if (todosCheck == true) { nodoPadre.set("checked", true); }
     
                        var nodoPadre2 = nodoPadre.parentNode; 
                        if (nodoPadre2 != null) {
                        var todosCheck2 = true;
                            nodoPadre2.cascade(function (childNode3) {
                                if ((childNode3.data.checked == false) && (nodoPadre2.data.text != childNode3.data.text)) {todosCheck2 = false; }
                            });   
                            if (todosCheck2 == true) { nodoPadre2.set("checked", true); }
                        }
                    }
                }
            this.locked = false;
        }
    };
    Thanks
  2. #2
    Hello!

    Coudln't reproduce with the sample below:

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <script>
                var onCheckChange = function (node, checked) {
                    if (!this.locked) {
                        this.locked = true;
    
                        if (node.hasChildNodes()) {
                            node.cascade(function (childNode) {
                                childNode.set("checked", checked);
                            });
                        }
    
                        var nodoPadre = node.parentNode;
                        if (nodoPadre != null) {
                            if (checked == false) {
                                nodoPadre.set("checked", false);
                                var nodoPadre2 = nodoPadre.parentNode;
                                if (nodoPadre2 != null) {
                                    nodoPadre2.set("checked", false);
                                }
                            } else {
                                var todosCheck = true;
                                nodoPadre.cascade(function (childNode2) {
                                    if ((childNode2.data.checked == false) && (nodoPadre.data.text != childNode2.data.text)) { todosCheck = false; }
                                });
                                if (todosCheck == true) { nodoPadre.set("checked", true); }
    
                                var nodoPadre2 = nodoPadre.parentNode;
                                if (nodoPadre2 != null) {
                                    var todosCheck2 = true;
                                    nodoPadre2.cascade(function (childNode3) {
                                        if ((childNode3.data.checked == false) && (nodoPadre2.data.text != childNode3.data.text)) { todosCheck2 = false; }
                                    });
                                    if (todosCheck2 == true) { nodoPadre2.set("checked", true); }
                                }
                            }
                        }
                        this.locked = false;
                    }
                };
            </script>
            
            <h1>Multi Node TreePanel built using markup</h1>       
            
            <ext:TreePanel 
                ID="TreePanel1" 
                runat="server" 
                Width="300" 
                Height="450" 
                Icon="BookOpen" 
                Title="Catalog" 
                AutoScroll="true">
                <TopBar>
                    <ext:Toolbar runat="server">
                        <Items>
                            <ext:Button ID="Button1" runat="server" Text="Expand All">
                                <Listeners>
                                    <Click Handler="#{TreePanel1}.expandAll();" />
                                </Listeners>
                            </ext:Button>
                            <ext:Button ID="Button2" runat="server" Text="Collapse All">
                                <Listeners>
                                    <Click Handler="#{TreePanel1}.collapseAll();" />
                                </Listeners>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <Root>
                    <ext:Node Text="Composers" Expanded="true" Checked="false">
                        <Children>
                            <ext:Node Text="Beethoven" Icon="UserGray" Checked="false">
                                <Children>
                                    <ext:Node Text="Concertos">
                                        <Children>
                                            <ext:Node Text="No. 1 - C" Icon="Music" Leaf="true" Checked="false" />
                                            <ext:Node Text="No. 2 - B-Flat Major" Icon="Music" Leaf="true" Checked="false" />
                                            <ext:Node Text="No. 3 - C Minor" Icon="Music" Leaf="true" Checked="false" />
                                            <ext:Node Text="No. 4 - G Major" Icon="Music" Leaf="true" Checked="false" />
                                            <ext:Node Text="No. 5 - E-Flat Major" Icon="Music" Leaf="true" Checked="false" />
                                        </Children>
                                    </ext:Node>
                                    <ext:Node Text="Quartets">
                                        <Children>
                                            <ext:Node Text="Six String Quartets" Icon="Music" Leaf="true" Checked="false" />
                                            <ext:Node Text="Three String Quartets" Icon="Music" Leaf="true" Checked="false" />
                                            <ext:Node Text="Grosse Fugue for String Quartets" Icon="Music" Leaf="true" Checked="false" />
                                        </Children>
                                    </ext:Node>
                                    <ext:Node Text="Sonatas">
                                        <Children>
                                            <ext:Node Text="Sonata in A Minor" Icon="Music" Leaf="true" Checked="false" />
                                            <ext:Node Text="sonata in F Major" Icon="Music" Leaf="true" Checked="false"  />
                                        </Children>
                                    </ext:Node>
                                    <ext:Node Text="Symphonies">
                                        <Children>
                                            <ext:Node Text="No. 1 - C Major" Icon="Music" Leaf="true" Checked="false" />
                                            <ext:Node Text="No. 2 - D Major" Icon="Music" Leaf="true" Checked="false" />
                                            <ext:Node Text="No. 3 - E-Flat Major" Icon="Music" Leaf="true" Checked="false" />
                                            <ext:Node Text="No. 4 - B-Flat Major" Icon="Music" Leaf="true" Checked="false" />
                                            <ext:Node Text="No. 5 - C Minor" Icon="Music" Leaf="true" Checked="false" />
                                            <ext:Node Text="No. 6 - F Major" Icon="Music" Leaf="true" Checked="false" />
                                            <ext:Node Text="No. 7 - A Major" Icon="Music" Leaf="true" Checked="false" />
                                            <ext:Node Text="No. 8 - F Major" Icon="Music" Leaf="true" Checked="false" />
                                            <ext:Node Text="No. 9 - D Minor" Icon="Music" Leaf="true" Checked="false" />
                                        </Children>
                                    </ext:Node>
                                </Children>
                            </ext:Node>
                        </Children>
                    </ext:Node>
                </Root>
                <SelectionModel>
                </SelectionModel>
                <BottomBar>
                    <ext:StatusBar ID="StatusBar1" runat="server" AutoClear="1500" />
                </BottomBar>
                <Listeners>
                    <CheckChange Fn="onCheckChange" />
                </Listeners>
            </ext:TreePanel>
        </form>
    </body>
    </html>
  3. #3
    Thanks Baidaly,

    I mean, when i checked a child the parent will chechked too..

    And now works perfectly. I just add Checked="false" and in treePanel, i add Listener for CheckChange :D. In my previous code i used CheckColumn and add CheckChange Listener inside the CheckColumn XD.

    Please mark as solved.

Similar Threads

  1. Replies: 4
    Last Post: Apr 17, 2013, 4:13 AM
  2. [CLOSED] Check child nodes treepanel
    By Antonio09 in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Jan 30, 2013, 12:29 AM
  3. Replies: 18
    Last Post: Jan 23, 2013, 3:20 PM
  4. Get TreePanel child nodes count
    By Maitreya in forum 1.x Help
    Replies: 2
    Last Post: Dec 13, 2012, 3:52 PM
  5. [CLOSED] check/uncheck for all child node in treepanel
    By majestic in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Nov 15, 2012, 3:11 AM

Tags for this Thread

Posting Permissions