So, if I want to use model to Json using the parent and child, first thing first, I need to put the data into the textarea :
{ "class": "go.TreeModel",
"nodeDataArray": [
{"key":1, "text":"Incorrect Deliveries", "size":18, "weight":"Bold"},
{"key":2, "text":"Skills", "size":14, "weight":"Bold", "parent":1},
{"key":3, "text":"knowledge", "weight":"Bold", "parent":2},
{"key":4, "text":"procedures", "parent":3},
{"key":5, "text":"documentation", "parent":4},
{"key":6, "text":"products", "parent":3},
{"key":7, "text":"literacy", "weight":"Bold", "parent":2},
{"key":8, "text":"Procedures", "size":14, "weight":"Bold", "parent":1},
{"key":9, "text":"manual", "weight":"Bold", "parent":8},
{"key":10, "text":"consistency", "parent":9},
{"key":11, "text":"automated", "weight":"Bold", "parent":8},
{"key":12, "text":"correctness", "parent":11},
{"key":13, "text":"reliability", "parent":11},
{"key":14, "text":"Communication", "size":14, "weight":"Bold", "parent":1},
{"key":15, "text":"ambiguity", "weight":"Bold", "parent":14},
{"key":16, "text":"sales staff", "weight":"Bold", "parent":14},
{"key":17, "text":"order details", "parent":16},
{"key":18, "text":"lack of knowledge", "parent":17},
{"key":19, "text":"telephone orders", "weight":"Bold", "parent":14},
{"key":20, "text":"lack of information", "parent":19},
{"key":21, "text":"picking slips", "weight":"Bold", "parent":14},
{"key":22, "text":"details", "parent":21},
{"key":23, "text":"legibility", "parent":21},
{"key":24, "text":"Transport", "size":14, "weight":"Bold", "parent":1},
{"key":25, "text":"information", "weight":"Bold", "parent":24},
{"key":26, "text":"incorrect person", "parent":25},
{"key":27, "text":"incorrect addresses", "parent":25},
{"key":28, "text":"customer data base", "parent":27},
{"key":29, "text":"not up-to-date", "parent":28},
{"key":30, "text":"incorrect program", "parent":28},
{"key":31, "text":"incorrect dept", "parent":25},
{"key":32, "text":"carriers", "weight":"Bold", "parent":24},
{"key":33, "text":"efficiency", "parent":32},
{"key":34, "text":"methods", "parent":32}
]}
And from the code below, it seems that the function below producing parent child key, so is it still neded?
function walkJson(obj, arr) {
var key = arr.length;
obj.key = key;
arr.push(obj);
var children = obj.causes;
if (children) {
for (var i = 0; i < children.length; i++) {
var o = children[i];
o.parent = key; // reference to parent node data
walkJson(o, arr);
}
}
}
// build the tree model
var nodeDataArray = [];
walkJson(json, nodeDataArray);
myDiagram.model = new go.TreeModel(nodeDataArray);
So after making the above changes, what else should I do?
Please point me the directions.
Many thanks