Hi Peter,
1. I want the user to be able to right click on a node and display a context menu?
You can have the context menu by right clicking the node. To display the context menu on the selected node and to add new nodes, following JavaScript is used.
// To display the contextmenu
function attachevent()
{
document.getElementById(''DiagramWebControl1'').oncontextmenu=function()
{
PosX = ConvertXYToDocument( Diagram.GetRootElement(), event.clientX, event.clientY, Diagram.GetMagnification() ).x;
PosY = ConvertXYToDocument( Diagram.GetRootElement(), event.clientX, event.clientY, Diagram.GetMagnification() ).y;
Popup.ShowPopup(event.clientX, event.clientY);
return false;
};
}
function OnContextMenuClick(Obj)
{
if(Obj.Text!="Edit")
{
Diagram.Refresh(Obj.Text+"|"+PosX+''|''+PosY);
}
else if(IsNodeSelected)
{
alert(''Not implemented'')
}
else
{
alert("Please select a Node to Edit");
}
return false;
}
2. Is it possible to know exactly what has been clicked on entirely on the client side, without a postback?
Yes, It is possible. From the client side itself you can get the item on which you have clicked.
if(Obj.Text!="Edit")
{
Diagram.Refresh(Obj.Text+"|"+PosX+''|''+PosY);
}
else if(IsNodeSelected)
{
alert(''Not implemented'')
}
Here you are getting the item text using "Obj.Text".
3. Also is there a way to select an block (or node) from the client side, by the right click.
Yes it is also possible. Please refer the below code which illustrates this:
PosX = ConvertXYToDocument( Diagram.GetRootElement(), event.clientX, event.clientY, Diagram.GetMagnification() ).x;
PosY = ConvertXYToDocument( Diagram.GetRootElement(), event.clientX, event.clientY, Diagram.GetMagnification() ).y;
Please refer the sample from the below link:
http://websamples.syncfusion.com/samples/Diagram.Web/5.2.0.25/F69957/main.htmPlease let me know if this helps you out.
Regards,
Raji