How to achieve tree view from JSON data using Angular 6 - treeview

I want to design a checkbox tree structure using following data coming from Web API using Angular 6. How can I achieve it please help.
[
{
"id": 1,
"parent_id": 0,
"Fund_type":"A&P"
},
{
"id": 2,
"parent_id": 1,
"Fund_type": "On Invoice"
},
{
"id": 3,
"parent_id": 2,
"Fund_type": "Banded packs-Consumer"
},
{
"id": 4,
"parent_id": 2,
"Fund_type": "Banded packs-Shopper"
},....]
Where id=1 is the root node and id=2 is the direct child of it and id=3 &4 are direct children of id=2(You can understand the structure from parent_id )
Thanks.

You need to change your data as per the example given below and use this component:
https://www.npmjs.com/package/ngx-treeview

You can simply use angular tree view in
https://www.syncfusion.com/angular-ui-components/angular-treeview

Related

Search by results of previous search in elasticsearch

It is possible to make a search by the results of another search?. For example:
// index: A
{ "ID": 1, "status": "done" }
{ "ID": 2, "status": "processing" }
{ "ID": 3, "status": "done" }
{ "ID": 4, "status": "done" }
// index: B
{ "ID": 1, "user": 1, "value": 10 }
{ "ID": 1, "user": 2, "value": 3 }
{ "ID": 2, "user": 1,"value": 1 }
{ "ID": 3, "user": 1, "value": 3 }
{ "ID": 4, "user": 1, "value": 7 }
Q1: Search in index "A" status == "done" and return the ID
RES: 1,3,4
Q2: From the results in Q1 search value > 5 and return the ID
RES: 1,4
My current solution is use two queries and download the results of "Q1" and make a second search in "Q2" but is very complicated because have 30k of results.
the problem to me seems to be more of a traditional union of filters in 2 indexes sort of a join , what we have in relational databases , not sure of the exact solution but recently had used a plug-in for the joins -> https://siren.io/siren-federate-20-0-introducing-a-scalable-inner-join-for-elasticsearch/ this might help

Partial Update in Eleastic Search Document

I just started exploring the elastic search and I stuck with a requirement in my project. I tried multiple thing but nothing worked for me. I have saved a sample document in elastic search index
"orderData": {
"lines": [
{
"lineNbr": 1,
"quantity": {
"amount": 1,
"uom": "EACH"
},
"weight": null,
"Qty": null
},
{
"lineNbr": 2,
"quantity": {
"amount": 1,
"uom": "EACH"
},
"weight": null,
"Qty": null
}
]
}
Next time I want to update only some of the data in line nbr one but here the problem is I dont want to do fields wise update. I get full Line Nbr 1 json again something like
{
"lineNbr": 1,
"quantity": {
"amount": 10,
"uom": "EACH"
},
"weight": 5,
"Qty": 5
}
But if I am performing update line nbr 2 tag is removed and only line nbr 1 tag is left with the updated data but I never wanted to touch line nbr 2
How can I achieve this? Any help will be appreciated. Thanks In Advance.

D3 Tree Graph Modified Data Model

I'm hoping to get opinions on what would be a good data model to drawing something like d3 tree graph. Tree graph won't work for me as is because I have scenarios where a child node could be linked with two parent nodes, sometimes, the parent nodes from different levels of hierarchy. I'm planning to modify d3 tree graph to use a different data model, and here's where I'd really appreciate expert opinions. Following is a simple representation of what I think the data model could be. One is hierarchical model and the other is flat. Has anyone actually meddled with d3 tree data model? Any help/opinions are greatly appreciated! Thanks in advance for the help!
var hierarchicalData = [
{
"id": "n1",
"children": [
{
"id": "n1-a",
"children":[
{
"id": "n1-a-1"
}
]
},
{
"id": "n1-b",
"children":[
{
"id": "n1-b-1"
}
]
}
]
},
{
"id": "n2",
"children": [
{
"id": "n2-a",
"children":[
{
"id": "n2-a-1"
}
]
}
]
}
];
The following is a flat representation of the exact same hierarchical model but contains "level" that represents hierarchy.
{
"n1":{
"level": 0,
"children": ["n1-a", "n1-b"],
},
"n1-a":{
"level": 1,
"children":["n1-a-1"]
},
"n1-a-1":{
"level": 2,
"children":[]
},
"n1-b":{
"level": 1,
"children":["n1-b-1"]
},
"n1-b-1":{
"level": 2,
"children":[]
},
"n2":{
"level": 0,
"children": ["n2-a"]
},
"n2-a":{
"level": 1,
"children": ["n2-a-1"]
},
"n2-a-1":{
"level": 2,
"children":[]
}
}
If a child node can have more than one parent, then it's not a tree graph by definition.
There are several UI approaches you may take if you want to have a tree but it really depends on what you're trying to accomplish.
I worked with d3 tree to present a company Org-chart.
Several companies have employees with a direct manager and secondary manager.
What we did is showing the connection only to the direct manager.
But we presented the link to the other manager on mouse-over on the employee node.
This is more of a UI solution than a data model solution and there are many other possibilities.
Another option is to do what My-heritage did with family tree. They're showing both parents of each node, but only one of them is connected to the rest of the tree presented.

Magento 2 API - Create shipping not updating order status

I am using the Magento 2 API call for creating shipments (/V1/shipment).
The shipment gets created in magento successfully, but the order status does not get moved to complete as I would expect.
My JSON request is as below:
{
"entity": {
"billingAddressId": 4,
"comments": [],
"items": [
{
"orderItemId": 2,
"qty": 2
}
],
"orderId": 2,
"shippingAddressId": 3,
"totalQty": 2,
"tracks": []
}
}
Thanks
It seems this is already a known bug in Magento as per here

Does Kendo UI DropDownList support grouping?

I'm using Kendo UI DropDownList but cannot find a way to group values in it. is this feature available?
saw the following post from early 2013 which says that this was on the roadmap, but not sure if it was implemented or not.
http://www.telerik.com/forums/option-group-for-datasource-in-dropdownlist
As of the Q1 2015 release, this is supported on the datasource. It doesn't look like you can do this when binding to local data though.
UserVoice Item
Demo
Grouping actually is supported now, in conjunction with the datasource. Here is a code snippet that will create a dropdown list using Kendo UI 2015.3.1111 and jQuery 1.9.1, grouping by team colors. The datasource, candidates, is a local array of data items. The dropdown list will replace an HTML element on the page, <input id="victim"/>.
var candidates = [
{ "id": 1, "name": "Alice", "team": "Red" },
{ "id": 2, "name": "Bob", "team": "Red" },
{ "id": 3, "name": "Charlie", "team": "Blue" },
{ "id": 4, "name": "Dorothy", "team": "Blue" },
{ "id": 5, "name": "Ed", "team": "Green" },
{ "id": 6, "name": "Frances", "team": "Green" },
{ "id": 7, "name": "George", "team": "Purple" },
{ "id": 8, "name": "Helen", "team": "Purple" },
];
$("#victim").kendoDropDownList({
"dataTextField": "name",
"dataValueField": "id",
"dataSource": { "data": candidates, "group": "team" },
"index": 0
});
This is what the dropdown looks like with stock styling in FireFox:
I hadn't noticed before, but the widget also orders the groups.
Grouping is not supported by the Kendo DropDownList widget.

Resources