Angular 6 Tree not able to load 1000000 nodes

256 views
Skip to first unread message

ashish biyahut

unread,
Jul 31, 2018, 1:44:02 AM7/31/18
to Angular and AngularJS discussion

Currently Angular tree not able to hold more than 30k nodes. For workaround I have used tree table and it was able to hold 80k nodes.

As per our requirement, we want an angular tree that can hold upto 1million nodes and it's child also.

Follow below steps to reproduce the issue:

Step 1 - Modify app.component.ts like below-

import { Component } from '@angular/core';
import { TreeNode } from 'primeng/components/common/treenode';

@component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {

selectedNodes: TreeNode[];
nodes: TreeNode[];
data: any;

constructor() {
this.nodes = [];
this.data = "";
}
ngOnInit() {
this.nodes = [];
this.data = "";

for (let i = 0; i < 100000; i++) {
  this.nodes.push(
    {
      label: "Node_" + i,
      data: "Backup Folder",
      expandedIcon: "fa fa-folder-open",
      collapsedIcon: "fa fa-folder"
    });
}

}
}
Step 2- Modify app.module.ts like this

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { TreeModule,TreeTableModule } from 'primeng/primeng';

@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
TreeModule,
TreeTableModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }

Step 3 - Modify app.component.html as below

I am using node version 10.6, angular version 6, primeng version 6

Sander Elias

unread,
Aug 6, 2018, 1:44:04 AM8/6/18
to Angular and AngularJS discussion
Hi Ashish,

As there is no tree in Angular I think you have an issue with a PrimeNg part?
Also, can you provide a sample and an explanation why you need so many elements in a page? Even without any framework, it's not recommended to put so many elements into a view.
Oh, and what is the question you have?

Regards
Sander

Ivan Ukraine

unread,
Aug 9, 2018, 12:31:25 PM8/9/18
to Angular and AngularJS discussion
Hi ashish biyahut,
You should use some library which not making 1 000 000 elements. It you have pagination and search
And make html elements only for displayed things not for all 1 000 000 elements.

But 1 000 000 elements. You will wait too long for response from server.
You should make ajax request for each table page and loading in dynamic to make shorter delay between user press your site and see result.
To make clients happy:) 

Regards
Ivan

Ivan Ukraine

unread,
Aug 9, 2018, 12:31:25 PM8/9/18
to Angular and AngularJS discussion
You should check this one I don`t know about how much nodes it will give you https://material.angular.io/components/tree/examples
Reply all
Reply to author
Forward
0 new messages