In the hierarchical structure, I have nodes as shown below:
Node - 1
Node-1-1
Node-1-1-1
Now I want to check if the connections between the parent and child nodes are defined.
Connections between parent and child are defined as below, for example, between Node -1 and Node -1-1:
"connections": {
"joins": [
{
"parent": "Node-1",
"child": "Node-1-1"
}
]
}
If there is at least one connection ( 1 entry in the connection properties connection ) between the parent and child nodes, then this is OK, I want to show a warning to the user and would like to return from the iteration function immediately if there is no connection between the nodes.
, , (.. ), id, .
Node -1-1 Node -1-1-1 , , .
, , .
var records = [
{
"name": "Node-1",
"nodes": [
{
"name": "Node-1-1",
"isParent": false,
"nodes": [
{
"name": "Node-1-1-1",
"isParent": false,
"nodes": [
],
"connections": {
"joins": []
}
}
],
"connections": {
"joins": [
{
"parent": "Node-1",
"child": "Node-1-1"
}
]
}
}
],
"isParent": true
}
];
function CheckConnections(){
var id=0;
iterate(records,
function (valid) {
if(valid)
{
id = id + 1;
console.log(id);
}
else
alert("please define connections")
}
);
}
function iterate(nodes,callback)
{
var connectionDefine = false;
callback(false);
}
<input type="button" value="Check Connections" onclick="CheckConnections()">
Hide result