Problem with 'collapse all' example
Hi,
I tried to use this example $("#tree").fancytree("getRootNode").visit(function(node){ node.setExpanded(false); });
But I get an error inside the function nodeRender [ (_assert(isRootNode || parent.ul, "parent UL must exist") ]. But the tree looks good.
When I use this for 'collapse all' $("#tree").fancytree("getRootNode").visit(function(node){ node.setExpanded(true); node.setExpanded(false); }); there is no error. But the tree expand completely and then collapse, which doesn't look good.
Any idea?
Thanks a lot!
does [Expand All] work for you on the sample page? http://wwwendt.de/tech/fancytree/demo/sample-api.html Could you send a sample that reproduces the problem?
[Expand All] and [Collapse All] work perfect for me on your example page. When I use your example tree in my code, then everything works fine, too.
This is my example
<ul id="ROOT_System" style="display: none;">
<li class="expanded" icon="/subsite/Custom/images/document_tree.png">
<a href="/Lists/RootNavigation/DispF.aspx?ID=1" target="_self" title="">Global</a>
<ul>
<li class="expanded folder" icon="/subsite/Custom/images/gear_in.png">
<span>[Title]</span>
<ul>
<li class="expanded folder" icon="/subsite/Custom/images/folder.png">
<span counter="true">Equipment</span>
<ul>
<li listGuid="Guids.Equipment" orderBy="Title" connection="preSystemID:preSystemID" icon="/subsite/Custom/images/gear_in.png">
<span>[Title]</span>
<ul>
<li class="folder expanded" icon="/subsite/Custom/images/folder.png" >
<span counter="true">Subequipment</span>
<ul>
<li listGuid="Guids.SubEquipment" orderBy="Title" connection="preSystemID:preSystemID;preEquipmentID:preEquipmentID" icon="/subsite/Custom/images/gear_in.png"><span>[Title]</span></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li id="id1.2" class="expanded folder" icon="/subsite/Custom/images/folder.png">
<span counter="true">Ships with same System</span>
<ul>
<li listGuid="{7844bc13-34f7-46f2-aabf-65276df9239f}" orderBy="Title" connection="preSystemID:preSystemID" icon="/subsite/Custom/images/schiff.png">
<span>[Title]</span>
<ul>
<li class="folder" icon="/subsite/Custom/images/folder_blue.png">
<span counter="true">Ship Documents</span>
<ul>
<li listGuid="{081aefd0-4410-46d9-bf1d-c79c025597f0}" orderBy="Title" connection="preSystemID:preSystemID;preSchiffID:preSchiffID" icon="/subsite/Custom/images/folder_document.png">
<span>[Title] ([preTaxKeyword])</span>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
I also tried it without the [span] tags, but without success.
I could reproduce this.
Something wrong with my tree?
no, but the collpase loop has a problem, whe a node was not yet rendered. as a workaround, you could try to skip collapsed nodes something like (not tested):
$("#tree").fancytree("getRootNode").visit(function(node){
if( !node.isExpanded() ) {
return false;
}
node.setExpanded(false);
});
i have some problem,so sad
This issue was fixed 3 years ago. Please open a new one, describing the exact problem and give a sample how it can be reproduced.