Comments (6)
I'm assuming you initialize reports with an empty array, and only later
initialize it with data?
You have 3 options:
- Use *ngIf to show tree only if reports has data
- Initialize reports with null instead of empty array.
- Use onUpdateData event instead of onInitialized (notice that every
time you update the pointer to reports this event will fire)
- Adam Klein http://il.linkedin.com/in/adamklein500
- CTO @ 500Tech.com http://500tech.com/
- AngularJS, ReactJS, NodeJS
- Development, consulting, training and public speaking
- (+972) 52 747 5633
On Tue, Sep 27, 2016 at 12:34 PM, Alexander Ciesielski <
[email protected]> wrote:
html
ts
@ViewChild('reportsTree') reportsTree: TreeComponent;
@input() reports: ReportTreeNode[];onTreeInitialized() {
console.log(this.reportsTree.treeModel);
console.log(this.reportsTree.treeModel.roots);
}export interface ReportTreeNode {
name: string;id?: number; children?: ReportTreeNode[];
}
Same result as above
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#58 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA2SSm-zDXYQT_D8OvVmb6a2cUQjJv9gks5quOMQgaJpZM4KDwaa
.
from angular-tree-component.
When are you doing console.log?
Have you tried in ngAfterViewInit ?
ngAfterViewInit() {
this.expandRoots()
}
Or in onInitialized
callback:
<Tree (onInitialized)="expandRoots()">
By the way, you can use the 'isExpanded' field for initial expand or collapse of nodes.
from angular-tree-component.
I have one root, with many children.
I'm debugging this way:
ngAfterViewInit() {
console.log(this.reportsTree.treeModel);
console.log(this.reportsTree.treeModel.roots);
}
It seems like the getter for roots in treeModel is buggy, since the first one prints the treeModel with roots array of length 1, but the second log prints an empty array []
from angular-tree-component.
Can you try using the (onInitialized) event instead of ngAfterViewInit?
BTW, the getter is fine. By the time you check the treeModel in the console
the roots are already there.
- Adam Klein http://il.linkedin.com/in/adamklein500
- CTO @ 500Tech.com http://500tech.com/
- AngularJS, ReactJS, NodeJS
- Development, consulting, training and public speaking
- (+972) 52 747 5633
On Tue, Sep 27, 2016 at 10:05 AM, Alexander Ciesielski <
[email protected]> wrote:
I'm debugging this way
ngAfterViewInit() {
console.log(this.reportsTree.treeModel);
console.log(this.reportsTree.treeModel.roots);
}It seems like the getter for roots in treeModel is buggy, since the first
one prints the treeModel with roots array of length 1, but the second log
prints an empty array [][image: screenshot from 2016-09-27 09-03-36]
https://cloud.githubusercontent.com/assets/17651898/18863416/77c00c7c-8491-11e6-879d-52927cb6d000.png—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#58 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA2SSvdZoD9vSUY8mUfgZBWgZ_Ud4WBGks5quMA1gaJpZM4KDwaa
.
from angular-tree-component.
html
<div class="report-tree-container">
<Tree #reportsTree
[nodes]="reports"
(onInitialized)="onTreeInitialized($event)"
(onActiveChanged)="onActiveChanged($event)">
</Tree>
</div>
ts
@ViewChild('reportsTree') reportsTree: TreeComponent;
@Input() reports: ReportTreeNode[];
onTreeInitialized() {
console.log(this.reportsTree.treeModel);
console.log(this.reportsTree.treeModel.roots);
}
export interface ReportTreeNode {
name: string;
id?: number;
children?: ReportTreeNode[];
}
Same result as above
from angular-tree-component.
reports
is initialized by parent component with async
pipe.
<app-report-list [reports]="reports | async" (select)="selectReport($event)">
</app-report-list>
Using onUpdateData
instead of onInitialized
fixed the issue, makes sense! Thanks!
from angular-tree-component.
Related Issues (20)
- Deactivate method for TreeNode
- How to Concatenate parent node with all children node HOT 1
- Missing documentation for how to use checkbox tri-state in a custom template HOT 2
- expandAll() method is very slow with large objects,even if virtual scroll is true HOT 1
- Typo in the template section of the documentation HOT 1
- selecting parent node does not select children with hasChildren true HOT 1
- No event for checkbox de-selection
- RTL doesn't work with Action Mapping
- Warning when publishing project in angular 14
- Select All option in tree view
- actionMapping mouse dblClick has stopped working HOT 1
- Expanding specific node on ngAfterViewInit
- Abandoned? HOT 1
- Add Expand/Collapse tooltips to expand/collapse arrows for better accessibility
- How to use whole new tree inside context menu HOT 1
- text while dragging node
- Module "@circlon/angular-tree-component" has no exported member 'IDTypeDictionary' HOT 1
- Angular 16 support HOT 22
- how can I know when the node is fully expanded?
- Solution: Low performance on scrolling. Performance boost
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-tree-component.