Move rows of table to swap positions

I have a go js diagram which uses table layout ,
I want to move the rows to swap position .
How can i do that?
This is my group template

const templateName = 'ListContainer';
        this.diagram.groupTemplateMap.add(templateName,
            $(go.Group, 'Auto',
                {
                    layerName: 'Background',
                    name: 'LIST_CONTAINER',
                    stretch: go.GraphObject.Fill,
                    width: 500,
                    height: 600,
                    selectable: false,
                    computesBoundsAfterDrag: false,
                    computesBoundsIncludingLocation: false,
                    handlesDragDropForMembers: false,
                    mouseDragEnter: function (e: go.InputEvent, group: any, prev: go.GraphObject) { group.isHighlighted = true; },
                    mouseDragLeave: function (e: go.InputEvent, group: any, next: go.GraphObject) { group.isHighlighted = false; },
                    mouseDrop: (e, obj) => this.listContainerGroupMouseDropHandler(e, obj)
                },
                new go.Binding('row'),
                new go.Binding('column', 'col'),
                $(go.Shape,
                    {
                        stroke: 'lightgray',
                        fill: 'white',
                        stretch: go.GraphObject.Fill,
                    },
                ),

                $(go.Panel, 'Auto', { name: 'LIST_CONTAINER' },
                    { width: 300, margin: 10 },
                    $(go.Shape,
                        {
                            stroke: 'lightgray',
                            fill: 'white',
                            stretch: go.GraphObject.Fill,

                        },

                    ),
                    $(go.Panel, 'Table',
                        {
                            name: 'POSITIONS_CONTAINER_DATA',
                            defaultRowSeparatorStroke: 'lightgray',
                            defaultRowSeparatorStrokeWidth: 1,
                            stretch: go.GraphObject.Fill,

                            itemTemplate: this.setupListRowContainerTemplate()
                        },
                        new go.Binding('itemArray', 'positions')
                    )

                )
            ));

I would do something like this. Caution – I haven’t tried this code!

// diagOrGroup is either a Diagram or a Group
// rowA and rowB must be non-negative integers
function swapRows(diagOrGroup, rowA, rowB) {
  if (rowA === rowB || rowA < 0 || rowB < 0) return;
  let diag = null;
  let grp = null;
  let coll = null;
  if (diagOrGroup instanceof go.Diagram) {
    diag = diagOrGroup;
    coll = diag.nodes;
  } else if (diagOrGroup instanceof go.Group) {
    grp = diagOrGroup;
    diag = grp.diagram;
    coll = grp.memberParts;
  } else {
    throw new Error("not a Diagram or a Group: " + diagOrGroup);
  }
  diag.commit(diag => {
    const Aparts = [];
    const Bparts = [];
    coll.each(part => {
      if (part instanceof go.Link) return;
      if (part.row === rowA) Aparts.push(part);
      else if (part.row === rowB) Bparts.push(part);
    });
    Aparts.forEach(part => part.row = rowB);
    Bparts.forEach(part => part.row = rowA);
    (grp ? grp : diag).layout.invalidateLayout();
  });
}

2 posts were split to a new topic: Selecting rows of parts

A post was merged into an existing topic: Selecting rows of parts