Hi, I have a problem, I want to modify the GridLayout’s wrappingColumn property of a Node meniante a ternary, whose variable is changing in a click method. But it doesn’t seem to take the change. Any ideas? Thanks in advance.
layout:
$(go.GridLayout,
{
wrappingColumn: changeDirection ? Infinity : 1, alignment: go.GridLayout.Position,
cellSize: new go.Size(1, 1), spacing: new go.Size(8, 8)
})
What is changeDirection? If it is just a JavaScript variable, changing that variable will not have any effect on the GridLayout instance that is your Diagram.layout. Try evaluating myDiagram.layout.wrappingColumn to see that it hasn’t changed. And if nothing has changed, there is no reason for the layout to be performed again.
You need to actually change a real property of the layout.
Yes, changeDirection is a javascript variable. I will check the myDiagram.layout.wrappingColumn, but then, in what way could I update that wrappingColumn? To make it dynamic in each event click.
Yes, I use the GraphObject.click event handler, and in the function (the one above, the one that says changeFirstSubGroupStyles ) I receive the argument e. And yes, I can access e.diagram, but my doubt is how to modify the template layout from there, using that e.diagram
Great, that works for me, but I have another question. If in that click event I wanted to modify the layout of the child groups that have that main group, would there be a way to do that? I mean, when you click, you modify the layout of both the main group and the interns.
You might want to check that all of the group members that you find are actually Groups, not regular Nodes, and that they actually have Group.layouts that are instances of GridLayout.
It appears that you are working with model data rather than with diagram nodes. Call Diagram.findNodeForData. Or just operate on Nodes rather than model data objects.