Code: Select all
[
{
"id":1,
"title":"My first title",
"comments":[
{
"id":1,
"comment":"onecomment"
},
{
"id":2,
"comment":"another comment"
}
],
"children":[
{
"id":2,
"title":"My first child of 1",
"comments":[
{
"id":100,
"comment":"a comment"
}
],
"children":[
{
"id":5,
"title":"grand child of 1 parent 2",
"comments":[
{
"id":100,
"comment":"a comment"
}
],
"children":[
]
},
{
"id":6,
"title":"grand child of 1 parent 2",
"comments":[
{
"id":200,
"comment":"comment 200"
},
{
"id":201,
"comment":" comment 201"
}
],
"children":[
]
}
]
},
{
"id":3,
"title":"My first child of 2",
"comments":[
{
"id":200,
"comment":"comment 200"
},
{
"id":201,
"comment":" comment 201"
}
],
"children":[
]
}
]
}
]
1) to find an example how to create another array with the format primeNg tree expects which is like this ( from here: https://github.com/primefaces/primeng/b ... files.json ):
Code: Select all
{
"data": [
{
"key": "0",
"label": "Documents",
"data": "Documents Folder",
"icon": "pi pi-fw pi-inbox",
"children": [{
"key": "0-0",
"label": "Work",
"data": "Work Folder",
"icon": "pi pi-fw pi-cog",
"children": [{ "key": "0-0-0", "label": "Expenses.doc", "icon": "pi pi-fw pi-file", "data": "Expenses Document" }, { "key": "0-0-1", "label": "Resume.doc", "icon": "pi pi-fw pi-file", "data": "Resume Document" }]
},
{
"key": "0-1",
"label": "Home",
"data": "Home Folder",
"icon": "pi pi-fw pi-home",
"children": [{ "key": "0-1-0", "label": "Invoices.txt", "icon": "pi pi-fw pi-file", "data": "Invoices for this month" }]
}]
},
{
"key": "1",
"label": "Events",
"data": "Events Folder",
"icon": "pi pi-fw pi-calendar",
"children": [
{ "key": "1-0", "label": "Meeting", "icon": "pi pi-fw pi-calendar-plus", "data": "Meeting" },
{ "key": "1-1", "label": "Product Launch", "icon": "pi pi-fw pi-calendar-plus", "data": "Product Launch" },
{ "key": "1-2", "label": "Report Review", "icon": "pi pi-fw pi-calendar-plus", "data": "Report Review" }]
},
{
"key": "2",
"label": "Movies",
"data": "Movies Folder",
"icon": "pi pi-fw pi-star",
"children": [{
"key": "2-0",
"icon": "pi pi-fw pi-star",
"label": "Al Pacino",
"data": "Pacino Movies",
"children": [{ "key": "2-0-0", "label": "Scarface", "icon": "pi pi-fw pi-video", "data": "Scarface Movie" }, { "key": "2-0-1", "label": "Serpico", "icon": "pi pi-fw pi-video", "data": "Serpico Movie" }]
},
{
"key": "2-1",
"label": "Robert De Niro",
"icon": "pi pi-fw pi-star",
"data": "De Niro Movies",
"children": [{ "key": "2-1-0", "label": "Goodfellas", "icon": "pi pi-fw pi-video", "data": "Goodfellas Movie" }, { "key": "2-1-1", "label": "Untouchables", "icon": "pi pi-fw pi-video", "data": "Untouchables Movie" }]
}]
}
]
}
and
2) how to relate the data of those two trees
For example if I click on the node of my ID:2 of the primeNG tree, how can I also have the comments array?
I am searching for an example everywhere but I cannot find anything. Have anoyne already done this and want to help please?