You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Changes that should be taken into account in order to migrate from __ng2-tree V1__ to __ng2-tree V2__](#changes-that-should-be-taken-into-account-in-order-to-migrate-from-__ng2-tree-v1__-to-__ng2-tree-v2__)
23
25
-[:bulb: Want to help?](#bulb-want-to-help)
24
26
@@ -124,7 +126,9 @@ Here is the fully stuffed *tree* tag that you can use in your templates:
124
126
(nodeRenamed)="handleRenamed($event)"
125
127
(nodeSelected)="handleSelected($event)"
126
128
(nodeMoved)="handleMoved($event)"
127
-
(nodeCreated)="handleCreated($event)">
129
+
(nodeCreated)="handleCreated($event)"
130
+
(nodeExpanded)="handleExpanded($event)"
131
+
(nodeCollapsed)="handleCollapsed($event)">
128
132
</tree>
129
133
```
130
134
@@ -147,6 +151,7 @@ Here is the definition of the `TreeModel` interface:
147
151
```typescript
148
152
interfaceTreeModel {
149
153
value:string|RenamableNode;
154
+
id:string|number;
150
155
children?:Array<TreeModel>;
151
156
loadChildren?:ChildrenLoadingFunction;
152
157
settings?:TreeModelSettings;
@@ -299,7 +304,7 @@ By default `rootIsVisible` equals to `true`
299
304
300
305
Also in the next section you'll be reading about events generated by the `ng2-tree`. And here [Tree](src/tree.ts) class comes in handy for us, because its instances propagated with event objects. Under the hood `ng2-tree` wraps a `TreeModel` provided by the user in `Tree`. And `Tree` in turn has lots of useful methods and properties (like `parent`, `hasChild()`, `isRoot()` etc.)
Here is the diagram that shows tree events' hierarchy
305
310
@@ -405,6 +410,40 @@ You can subscribe to `NodeRenamedEvent` by attaching listener to `(nodeRenamed)`
405
410
}
406
411
```
407
412
413
+
#### NodeExpandedEvent
414
+
415
+
You can subscribe to `NodeExpandedEvent` by attaching listener to `(nodeExpanded)` attribute, this event wont fire on initial expansion
416
+
417
+
```html
418
+
<tree
419
+
[tree]="tree"
420
+
(nodeExpanded)="handleExpanded($event)">
421
+
</tree>
422
+
```
423
+
424
+
`NodeExpandedEvent` has a `node` property of type `Tree`, which contains an expanded node.
425
+
426
+
```typescript
427
+
{node: <Tree>{...}}
428
+
```
429
+
430
+
#### NodeCollapsedEvent
431
+
432
+
You can subscribe to `NodeCollapsedEvent` by attaching listener to `(nodeCollapsed)` attribute
433
+
434
+
```html
435
+
<tree
436
+
[tree]="tree"
437
+
(nodeCollapsed)="handleCollapsed($event)">
438
+
</tree>
439
+
```
440
+
441
+
`NodeCollapsedEvent` has a `node` property of type `Tree`, which contains a collapsed node.
442
+
443
+
```typescript
444
+
{node: <Tree>{...}}
445
+
```
446
+
408
447
## Changes that should be taken into account in order to migrate from __ng2-tree V1__ to __ng2-tree V2__
409
448
- Events were reworked:
410
449
- In V1 all events that were inherited from NodeDestructiveEvent used to have property `parent`. It's not the case anymore. If you need a parent you should get it from `node` in event object like `node.parent`;
0 commit comments