How to use other attributes as category?

consider i have a json
{“nodeDataArray”:[{“ObjectType”:10,“figure”:“cylinder3”,“visible”:true,“Description___3”:…soo on}]
what i want is i want to use ObjectType as the category that select the template and how to set is group to true on the basis of ObjectType?

The first question is easy: set Model | GoJS API to “ObjectType”. I recommend that you do so before you assign Model.nodeDataArray.

The second question is similar but a bit more tricky: set GraphLinksModel | GoJS API to a function such as:

function(data) { return data.ObjectType === "someGroupCategory"; }

or whatever you want that consistently returns true only when you want that node data object to be treated as a group. No side effects!

But the tricky part is that if you use Model.toJson and Model.fromJson, that function cannot be saved into JSON-formatted text. So either you need to serialize your models in some other manner, or when you call Model.fromJson you make sure to then set Model.nodeIsGroupProperty to your predicate function before you use the model in any manner. In particular before you set Diagram.model.

That last bit applies for all model properties that you want to be functions – they cannot be saved in JSON text so you need to set them each time you create a model and before setting Diagram.model.