Dropping nodes in blank area


We are creating organization chart using GoJS where user can drag and drop nodes from Pallete (something similar http://gojs.net/latest/samples/flowchart.html) in chart. While drag-drop on valid node is working fine, I need help in following :

  1. User should not be able to drop node on blank area of chart, and should be able to drop only on existing node. If user tries to drop I need to delete and show alert.

  2. When user drags node from Pallete and brings it over a node on chart, I need to highlight node where it will be added.


To disallow dropping onto the background of the diagram (not on a Node or a Link):
$(go.Diagram, “myDiagramDiv”,
{ . . . ,
// don’t allow dropping onto the diagram’s background
mouseDrop: function(e) { e.diagram.currentTool.doCancel(); },
. . . })

The Org Chart Editor sample, http://gojs.net/latest/samples/orgChartEditor.html, demonstrates how to have the stationary Node (where the drop would happen) be highlighted. The Planogram sample, http://gojs.net/latest/samples/planogram.html, does that too.