EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Aod47 on July 24, 2015, 11:03:49 PM



Title: tree create infinite child element
Post by: Aod47 on July 24, 2015, 11:03:49 PM
Tree create infinite child element. :o

Please see the attach file

I applied code from demo.

May be something wrong in json file.

Could you please advice?

Thank you.

Code:
<body>
    <h2>CheckBox Tree</h2>
    <p>Tree nodes with check boxes.</p>
    <div style="margin:20px 0;">
        <a href="#" class="easyui-linkbutton" onclick="getChecked()">GetChecked</a>
    </div>
    <div style="margin:10px 0">
        <input type="checkbox" checked onchange="$('#tt').tree({cascadeCheck:$(this).is(':checked')})">CascadeCheck
        <input type="checkbox" onchange="$('#tt').tree({onlyLeafCheck:$(this).is(':checked')})">OnlyLeafCheck
    </div>
    <div class="easyui-panel" style="padding:5px">
        <ul id="tt" class="easyui-tree" data-options="url:'treedata3.json',method:'get',animate:true,checkbox:true"></ul>
    </div>
    <script type="text/javascript">
        function getChecked(){
            var nodes = $('#tt').tree('getChecked',['checked','indeterminate']);
console.log(nodes);
            var s = '';
            for(var i=0; i<nodes.length; i++){
                if (s != '') s += ',';
                s += nodes[i].id;
            }
            alert(s);
        }
    </script>
</body>


Title: Re: tree create infinite child element
Post by: stworthy on July 25, 2015, 12:16:09 AM
You can not set the leaf node with 'closed' state. Please correct your json data and try again.
Code:
[
 {"id":100,"text":"Configuration","iconCls":"icon-save","state":"closed","children":[
{"id":110,"text":"User Control","iconCls":"icon-save"},
{"id":120,"text":"System Setting","iconCls":"icon-save"},
{"id":130,"text":"Module Setting","iconCls":"icon-save"}]
 },
...


Title: Re: tree create infinite child element
Post by: Aod47 on July 25, 2015, 06:35:50 AM
It's work now. Thank you very much.