@namisha wrote:
Hi I'm using a pallete to drop nodes on my canvas. I'm using a gridlayout so my nodes are aligned horizontally whenever they are dropped on canvas. However i want to manually move a particular node and change its position. The node is moved but whenever a new node is dropped or a current one is deleted, the entire diagram realigns all the nodes horizontally again which i need to restrict.
This is my myDiagram object:
myDiagram = $(go.Diagram, "diagramDiv", // create a Diagram for the DIV HTML element
{
layout: $(go.GridLayout, {spacing: new go.Size(20,20)}), // { comparer: go.GridLayout.smartComparer } go.GridLayout
initialContentAlignment: go.Spot.Left, // left align the content
"undoManager.isEnabled": true // enable undo & redo
});This is my Listener for External Objects Dropped
myDiagram.addDiagramListener("ExternalObjectsDropped", function (e) { debugger; myDiagram.layout.invalidateLayout(); myDiagram.layoutDiagram(); if(findNode != null) previousNode = findNode; findNode= myDiagram.model.findNodeDataForKey(e.subject.ji.key.Pd.key); var findKey = myPalette.model.findNodeDataForKey(e.subject.ji.key.Pd.key); currentNode= findNode; if (findKey !== null && findKey.key !== "String") { myPalette.model.setDataProperty(findKey, "color", "grey"); myPalette.model.setDataProperty(findKey, "isPickable", false); } if (e.subject.ji.key.Pd.key == "String") { document.getElementById('paletteLineups').style.backgroundColor = 'white'; myPalette1.model.startTransaction("Enable Palette"); for (var i = 0; i < myPalette1.model.nodeDataArray.length; i++) { var data = myPalette1.model.nodeDataArray[i]; myPalette1.model.setDataProperty(data, "isPickable", true); } myPalette1.model.commitTransaction("Enable Palette"); } myDiagram.startTransaction("make link"); if(root === null){ root=currentNode; } if(!(currentNode === root) && !(currentNode.key.includes("String"))){ myDiagram.model.addLinkData({from: previousNode.key, to: currentNode.key }); } myDiagram.commitTransaction("make link");});
Posts: 4
Participants: 2