how to make the parent mxcell in mxgraph javascript library

592 Views Asked by At

I am using mxgraph javascript library. Scenario: one swim lane is added to the graph. Any shapes can be added as a child to the swimlane (drag and drop).We can add 'n' number of childs . how to make the swimlane size fixed irrespective of number of childs .When i insert more child vertex in different places, parent mxcell size getting changed.

expected child as below:

enter image description here

Tried with extendParentsOnAdd/autoextend property. Objects in child are overlap on each other as below enter image description here

1

There are 1 best solutions below

3
On

I suggest you to give a try to the mxgraph.extendParentsOnAdd property which seems to configure exactly what you are looking for: https://jgraph.github.io/mxgraph/docs/js-api/files/view/mxGraph-js.html#mxGraph.extendParentsOnAdd and set it to false

Specifies if parents should be extended according to the extendParents switch if cells are added. Default is true.

You may also have to configure https://jgraph.github.io/mxgraph/docs/js-api/files/view/mxGraph-js.html#mxGraph.extendParents

Specifies if a parent should contain the child bounds after a resize of the child. Default is true. This has precedence over constrainChildren.

There are also other configuration properties about auto extend, like https://jgraph.github.io/mxgraph/docs/js-api/files/view/mxGraph-js.html#mxGraph.autoExtend (this one is generally useful at graph load time when you provide the intial graph definition)

Notice that this question seems very close to Set mxgraph cell only draggable within the canvas width