Components: Mat Tree ExpandAll doesn't work

Created on 12 Jul 2018  路  3Comments  路  Source: angular/components

Bug, feature request, or proposal:

Bug

What is the expected behavior?

Collapse All/Expand All on Nested Tree Control

What is the current behavior?

The expandAll() in nested-tree-control.ts function doesn't work. this.dataNodes is undefined

What are the steps to reproduce?

https://angular-7dvgw3.stackblitz.io

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

@angular/material 6.3.3

P4 materiatree

Most helpful comment

I checked the source code and judging from the test file you have to set the dataNodes value yourself.

Notice the treeControl.dataNodes = nodes; before calling expandAll()
https://github.com/angular/material2/blob/adda21f5c2d47ce12620567cda9494e68d092339/src/cdk/tree/control/nested-tree-control.spec.ts#L74-L93

All 3 comments

I have the same problem. I simply added a call to expandAll() to the example from the doc: https://ynxoygyknxk.angular.stackblitz.io/

See the console for the error.

I checked the source code and judging from the test file you have to set the dataNodes value yourself.

Notice the treeControl.dataNodes = nodes; before calling expandAll()
https://github.com/angular/material2/blob/adda21f5c2d47ce12620567cda9494e68d092339/src/cdk/tree/control/nested-tree-control.spec.ts#L74-L93

Ran into the same issue. From testing it does appear there is a dependency on expandAll /collapseAll /expand etc. relying treeControl.dataNodes field. When I look at the examples here: [https://material.angular.io/components/tree/examples] I notice that the first example populates dataNodes but the others don't.

That said, this case can probably be closed as a duplicate of the issue noted here : https://github.com/angular/material2/issues/12469. Not sure if ultimately the problem is just documentation OR if there is a "bug".

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dzrust picture dzrust  路  3Comments

crutchcorn picture crutchcorn  路  3Comments

theunreal picture theunreal  路  3Comments

Miiekeee picture Miiekeee  路  3Comments

MurhafSousli picture MurhafSousli  路  3Comments