My array represents different groups, structured like so:
- Company Name
- IT
- Finance
- Global Finance
- Financial Department
- Tax and Co.
- Global Finance
My goal is to select a specific node (such as Financial Department) and create a new array containing that node and its parent nodes (Global Finance, Finance, and Company Name, which is the static root node).
I am working with AngularJS (specifically angular-ui-tree and angular-ui-tree-filter) and have access to jQuery, third-party libraries, and more.
Is there an efficient method to achieve this? Before attempting it myself, I figured I would inquire here in case someone has already tackled a similar task.
Example of the Array:
$scope.groups = [{
"id": 1,
"title": "Company Name",
"selected": "",
"enabled": "",
"CampaignId": "string",
"TenantId": "string",
"CompanyId": "string",
"items": [{
"id": 2,
"title": "Board of Directors",
"selected": "",
"enabled": "",
"CampaignId": "string",
"TenantId": "string",
"CompanyId": "string",
"items": []
}, {
"id": 3,
"title": "Finance",
"selected": "",
"enabled": "",
"CampaignId": "string",
"TenantId": "string",
"CompanyId": "string",
"items": [{
"id": 4,
"title": "Global Finance",
"selected": "",
"enabled": "",
"CampaignId": "string",
"TenantId": "string",
"CompanyId": "string",
"items": [{
"id": 5,
"title": "Financial department",
"selected": "",
"enabled": "",
"CampaignId": "string",
"TenantId": "string",
"CompanyId": "string",
"items": []
}, {
"id": 6,
"title": "Region Asia Pacific",
"selected": "",
"enabled": "",
"CampaignId": "string",
"TenantId": "string",
"CompanyId": "string",
"items": []
}]
}, {
"id": 7,
"title": "Tax & Co.",
"selected": "",
"enabled": "",
"CampaignId": "string",
"TenantId": "string",
"CompanyId": "string",
"items": []
}]
}, {
"id": 8,
"title": "Sales",
"selected": "",
"enabled": "",
"CampaignId": "string",
"TenantId": "string",
"CompanyId": "string",
"items": []
}, {
"id": 9,
"title": "Manufacturing",
"selected": "",
"enabled": "",
"CampaignId": "string",
"TenantId": "string",
"CompanyId": "string",
"items": []
}
}];