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

How to collapse node at initialization? #102

Closed
lynings opened this issue Jun 12, 2017 · 5 comments
Closed

How to collapse node at initialization? #102

lynings opened this issue Jun 12, 2017 · 5 comments

Comments

@lynings
Copy link

lynings commented Jun 12, 2017

And how to set whether node is expanded?
Because In the initialization or call loadChildren function, when the tree is too high, this is a very bad user experience.

@rychkog
Copy link
Contributor

rychkog commented Jun 13, 2017

@lynings don't have this option right now.

One way to do it - by using API developed in scope of #78

The other, with an ability to define in settings which node should be collapsed, is being developed.

@rajeshkdev
Copy link

"The other, with an ability to define in settings which node should be collapsed, is being developed."

@rychkog Any updated on the above comment of yours?
Is it now possible to define in settings that node should be collapsed/expanded?

@rychkog
Copy link
Contributor

rychkog commented Nov 12, 2017

@rajeshkdev Will be available in a next release (during the next week).

@rajeshkdev
Copy link

@rychkog Thank you so much. That would solve my big headache. Looking forward your updates.

rychkog pushed a commit that referenced this issue Nov 19, 2017
feat(tree): make it possible to collapse a tree on a first load. Closes #102
@rajeshkdev
Copy link

This implementation is available ng2-tree v2.0.0-rc.2 version onwards.

The following flag need to be set to collapse by default. Else it will be all the expanded .

isCollapsedOnInit: true,

public treeViewConfig() {
        const ffs: TreeModel = {
            value: this.appConfig.rootNode,
            id: 1,
            settings: {
                isCollapsedOnInit: true,
                cssClasses: {
                    expanded: 'fa fa-caret-down',
                    collapsed: 'fa fa-caret-right',
                    empty: 'fa fa-caret-right disabled',
                    leaf: 'fa'
                },
                templates: {
                    node: '<i class="fa fa-folder"></i>',
                    leaf: '<i class="fa fa-file"></i>'
                },
                leftMenu: false,
                rightMenu: false
            },
            children: []
        };
        return ffs;
    }

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

No branches or pull requests

3 participants