Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collapse all on load and then collapse level-by-level #27

Open
DarthSonic opened this issue Nov 15, 2022 · 2 comments
Open

Collapse all on load and then collapse level-by-level #27

DarthSonic opened this issue Nov 15, 2022 · 2 comments

Comments

@DarthSonic
Copy link

closeDepth: 1 will help me to only show the first level of the tree with all collapsed.

If I click on an item it will open, but it opens all childrens not only the next level/children. How can I prevent this?

@ChrBaum
Copy link

ChrBaum commented Nov 24, 2022

I solved this issue by using the collapseAll() function in the built-in loaded function:

  let newTree = function(data){
    let tree = new Tree('.container', {
    data: data,
    closeDepth: 1,
    loaded: function () {
      this.collapseAll()
      },
      onChange: function () {
      }
    })
  }

@AlexBDXMET
Copy link

AlexBDXMET commented Sep 29, 2023

`function preventChildExpansion() {

$('.treejs-switcher').each(function () {
    var $parent = $(this).closest('.treejs-node');
    if (!$parent.hasClass('treejs-node__close')) {
        $parent.addClass('treejs-node__close');
    }
});

}`

Then, when tree is loaded :
loaded: function () { preventChildExpansion(); }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants