Saved group position

Hi,

I can’t manage a very strange behaviour regarding the location parameter of a group…When I save all the json string in the db it’s seems all ok, but when I recall the string and load it into the model its X coordinates have changed… I debugged it on firefox and all is ok before this:

myDiagram.model = go.Model.fromJson(JSON.parse($.parm_conf));

where $.parm_conf=..."nodeDataArray":[{"isGroup":true,"group":"Somma","text":"Somma","loc":"238 -13.5 "..., that
become ..."nodeDataArray":[{"isGroup":true,"group":"Somma","text":"Somma","loc":"1 -13.5"...
in the graphic and in the textbox… Why only the x coordinates have changed?
Can you tell me what’s going on?
Thx

Presumably your Group has a Placeholder, yes? And you have a TwoWay Binding on the group’s “location” property, yes?

When a group is expanded the union of the areas occupied by its member nodes is determining the location and size of the placeholder, so any saved “loc” value in the group’s node data object is ignored when you load it.

Yes & Yes…So there’s no way to save its old position? There’s a way to place the group just in the middle of the canvas? If yes, how? (obviously in the loading phase…)

“in the middle of the canvas” sounds like you want to scroll the whole diagram so that a particular group is in the middle of the viewport. Is that what you really want? That’s a matter of calling CommandHandler.scrollToPart or Diagram.centerRect.

Or did you want to move (i.e. change the Part.location) the group and all of its members as well? That cannot be done with a data binding, but can be achieved by calling Group.move or Group.moveTo.

the second choice…Nooo… I don’t want to scroll anything…
But in order to use Group.move or Group.moveTo how can I establish right coordinates? Just to be clear, for example if I want to move the group to its previous coordinates I need to pass to “move” function the coordinates in their original string format or something else? Is there an example?

I don’t understand the question. Just call https://gojs.net/latest/api/symbols/Part.html#move on the Group that you want to move.

sorry for my very bad english… What I really mean is that I have a string with x-y coordinates coming from the imported json: now in order to move the group during the “init” what I need to do? I must to convert that coordinates string in Point format and pass it to Group.move function? Is that possible in the init phase?

Oh. How was the string generated? If it was by the static Point.stringify function, just call Point.parse.

someGroup.move(go.Point.parse(somestring))

And your English is fine, by the way. Most of the people in this forum do not have English as their first language. It isn’t for me either.

Many thanks Walter!