As you see the nodes in “Components” tab, it loaded dynamically. now this is working fine when i drag them from palette to diagram it will create new node but I want these nodes to be loaded dynamically in context menu instead of palette “Components” tab with showing only their title as String and when i click on that title it will create new node with the text “title” on it. how could I achieve this ?
Have you read GoJS Context Menus -- Northwoods Software ?
Did you want to create a context menu in GoJS or in HTML?
yeah i check this link … and i am creating context menu in GOJs
It is uncommon to want to define a context menu from entirely new elements each time, but it can be done easily enough.
Here’s an example of defining a context menu for the whole Diagram (i.e. the background of the diagram) whose context menu buttons are completely determined at run-time by an Array.
$(go.Diagram, . . .,
{ . . .,
contextMenu: $("ContextMenu"),
contextClick: function(e) {
var cm = e.diagram.contextMenu;
// remove all existing buttons
while (cm.elements.count > 0) cm.removeAt(0);
// now create all buttons according to the data in the Choices variable
Choices.forEach(function(name) {
cm.add($("ContextMenuButton",
$(go.TextBlock, name),
{
click: function(e, button) {
alert("context menu command: '" + name + "'");
}
}
))
});
}
});
var Choices = ["command one", "choice two", "third"];
thank you for your quick reply. i will implement this !