fancytree icon indicating copy to clipboard operation
fancytree copied to clipboard

Problem with 'collapse all' example

Open funlovin opened this issue 13 years ago • 7 comments

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!

funlovin avatar Dec 04 '13 16:12 funlovin

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?

mar10 avatar Dec 05 '13 09:12 mar10

[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.

funlovin avatar Dec 05 '13 14:12 funlovin

I could reproduce this.

mar10 avatar Dec 05 '13 18:12 mar10

Something wrong with my tree?

funlovin avatar Dec 05 '13 20:12 funlovin

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);
});

mar10 avatar Dec 06 '13 07:12 mar10

i have some problem,so sad

q640202047 avatar Jun 08 '17 02:06 q640202047

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.

mar10 avatar Jun 08 '17 04:06 mar10