We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Right Click Select and Context Menu

Thread ID:

Created:

Updated:

Platform:

Replies:

69957 Nov 20,2007 10:57 AM UTC Nov 21,2007 02:45 PM UTC ASP.NET Web Forms (Classic) 1
loading
Tags: DiagramWebControl
Peter Swallow
Asked On November 20, 2007 10:57 AM UTC

Hi,

I have a diagram with blocks and links.

I want the user to be able to right click on a node and and display a context menu, with items specific to that node.

Is it possible to know exactly what has been clicked on entirely on the client side, without a postback?

Also is there a way to select an block (or node) from the client side, by the right click.

Thanks,

Pete


Rajarajeswari S [Syncfusion]
Replied On November 21, 2007 02:45 PM UTC


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.htm

Please let me know if this helps you out.

Regards,
Raji



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;