Key, parent Alternatives?

When binding to an external datasource you are never likely to have object properties called ‘key’ and ‘parent’.

Is it possible to tell the go model to use different fields (e.g. ‘employeeId’ and ‘managerId’) for ‘key’ and ‘parent’ properties?

At the moment I have to create a new model from my service model e.g.
“EmployeeId”: 1,
“KnownAs”: “Jim”,
“ManagerId”: 0
“EmployeeId”: 26,
“KnownAs”: “Andrew”,
“ManagerId”: 1
has to become
“key”: 1,
“KnownAs”: “Jim”,
“parent”: 0
“key”: 26,
“KnownAs”: “Andrew”,
“parent”: 1

Not the end of the world but it would be better if GoJS handled this by being able to point alternative fields to the key/parent fields rather than having to code around this for both the GET and the POST.


So you are using a TreeModel to hold that Array of node data objects that you read from JSON-formatted text?

If so, all you need to do is set TreeModel.nodeKeyProperty to “EmployeeId” and TreeModel.nodeParentKeyProperty to “ManagerId”. It’s more efficient if you set those two properties before setting Model.nodeDataArray.

nice one, works a treat… for some reason I missed that on the api!