[SOLVED] Get the sort order of the Swimlanes

Hi,

How can i get the sort order of the swimlanes? I want to re-order them and save their actual order in the DB

Regards,

That’s already possible in the linked sample. Drag Lane 3 above Lane 2 for instance, and they will swap places and be kept on save and load.

linked sample is… Pool (1) ? I tried but the order of Lanes doesnt change in myDiagram.model.toJson();

The visual order of the lanes is based on their locations, and the locations change.

In general the order of data objects in the Model.nodeDataArray should be independent of how Nodes are positioned in the Diagram. That doesn’t mean there can’t be any correlation, but if you care about positioning, you need to make sure things are ordered/sorted by the diagram.

The other way to look at it is that many databases do not guarantee the order in which records are retrieved, unless you explicitly order them or they are ordered by some additional mechanisms.

Another consideration is that sorting Arrays in Firefox and IE are usually “stable”, whereas sorting in Chrome is usually “unstable”, thereby causing different results between the browsers.

ah Ok. so, It means only with the change of “loc” property of the Lanes will be enough to show the Lanes ordered after the save process in DB, right?

Yes. You can prove that they will be ordered correctly after a save and load by typing:

myDiagram.model = go.Model.fromJson(myDiagram.model.toJson())

in the console and seeing them stay in the correct positions.