I have a json file in my Angular project with a flat array like so ...
[
{
"id": 1,
"name": "Demo1",
"parentId": 0
},
{
"id": 2,
"name": "Demo2",
"parentId": 1
},
{
"id": 3,
"name": "Demo3",
"start": "24/09/2021 11:00:00",
"end": "30/09/2021 12:00:00",
"parentId": 2
},
{
"id": 4,
"name": "Demo4",
"start": "24/09/2021 11:00:00",
"end": "",
"parentId": 3
}
]
I need to display this data inside Ag Grid with a tree structure. But for Tree structure to work it needs a path property like path: [demo1]; [demo1, demo2]; [demo1, demo2, demo3]
I need help with creating the path variable dynamically and adding it back to main array.
I can then use this path in the getDataPath function for Ag grid.
this.getDataPath = function (data) {
return data.path;
};
You can refer to this link for Ag grid tree data : https://www.ag-grid.com/angular-data-grid/tree-data/