Hi Jim
Thanks for using Syncfusion products.
We have created a simple sample to represent how to render context menu. We suggest you to set “Diagram1.Model.EnableContextMenu as true” to render context menu. To render a specific context menu item, please follow the below code snippet. We have some issues in rendering specific context menu item and in custom context menu. The fix for this issue is estimated to be available on service pack release, which is scheduled to release in the end of November.
$(window).load(function () {
var diagram = $("#Diagram1").data("ejDiagram");
var contextMenu = $.extend(true, {}, diagram.model.contextMenu);
$("#Diagram1").ejDiagram({
//render context menu
contextMenu:
contextMenu
})
});
//render a particular contextmenu item
ej.datavisualization.Diagram.Locale["en-US"] = {
cut: "Cut",
}
Sample:http://www.syncfusion.com/downloads/support/directtrac/general/WebApplication21_(2)-1979191829.zip
Please let me know if any concerns.
Regards,
Shyam G
Hi Jim
Thanks for the update.
Query |
Response |
Thanks for the code, but let me do a better job of
explaining my requirement. |
We are glad to inform you that we have created a sample to
render custom context menu and it is available in the below link for download.
Please see the code snippet below. var diagramId = "Diagram1"; $(window).load(function () { var diagram = $("#Diagram1").data("ejDiagram"); var contextMenu = $.extend(true, {}, diagram.model.contextMenu);
contextMenu.items.push({ name: "process", text: "process" }, { name: "process1", text: "process1" }, { name: "process2", text: "process2" }, { name: "process3", text: "process3" }); $("#Diagram1").ejDiagram({
contextMenu: contextMenu }); });
ej.datavisualization.Diagram.Locale["en-US"] = { cut: "Cut", copy: "Copy", paste: "Paste", undo: "Undo", redo: "Redo", selectAll: "SelectAll", grouping: "Grouping", group: "Group", ungroup: "Ungroup", order: "Order", bringToFront: "BringToFront", moveForward: "MoveForward", sendBackward: "SendBackward", sendToBack: "SendToBack", //custom menu process: "process", process1: "process1", process2: "process2", process3: "process3", } function nodeclick(args) { var diagram = $("#Diagram1").data("ejDiagram"); var node = diagram.selectionList[0]; if (node) { if (node.addInfo.Id == "one") {
document.getElementById(diagramId + "_contextMenu_process2").style.display = "none";
document.getElementById(diagramId + "_contextMenu_process3").style.display = "none";
document.getElementById(diagramId + "_contextMenu_process").style.display = "block";
document.getElementById(diagramId + "_contextMenu_process1").style.display = "block"; } if (node.addInfo.Id == "two") { document.getElementById(diagramId
+ "_contextMenu_process").style.display = "none";
document.getElementById(diagramId + "_contextMenu_process1").style.display = "none";
document.getElementById(diagramId + "_contextMenu_process2").style.display = "block";
document.getElementById(diagramId + "_contextMenu_process3").style.display = "block"; } }
}
Sample:http://www.syncfusion.com/downloads/support/directtrac/general/customcontextmenu555266111.zip Currently we have an issue in “contextMenuClick” event. We have already logged a defect report
and fix for this issue is estimated to be available on volume 4 2014 release,
which is scheduled to release in the mid of December. Please note that you need to define default context menu along
with the custom menu in “ej.datavisualization.Diagram.Locale["en-US"]” and you cannot define custom menu alone
in “ej.datavisualization.Diagram.Locale["en-US"]” . We have
already logged a defect report and fix for this issue is estimated to be
available on volume 4 2014 release, which is scheduled to release in the mid
of December. |
Can the use of your ejMenu be employed in this
solution? |
We are currently analyzing on your requirement of including
ejMenu(context menu) in the diagram. However we will update you with more
information in one business day(12/17/2014). |
Please let me know if any concerns.
Regards,
Shyam G
Hi Jim
Thanks for your patience
Query |
Response |
Can the use of your ejMenu be employed in this
solution? |
We are glad to inform you that we have created a sample of
custom context menu using ejMenu in the diagram. Sample:http://www.syncfusion.com/downloads/support/directtrac/general/ejmenu-1077544391.zip Please see the event below which is used in the context menu. 1.“ClientSideOnBeforeContextOpen”-
This event fires before context menu gets open. Code
snippet: <ej:Menu ID="Menu1" MenuType="ContextMenu" ClientSideOnBeforeContextOpen="open" OpenOnClick="false" runat="server" ContextMenuTarget="#Diagram1">
</ej:Menu> function open(args) { var diagram = $("#Diagram1").data("ejDiagram"); var node = diagram.selectionList[0]; if (node) { if (node.addInfo.Id == "one") {
document.getElementById("process").style.display = "none";
document.getElementById("process1").style.display = "none";
document.getElementById("process2").style.display = "block";
document.getElementById("process3").style.display = "block"; } if (node.addInfo.Id == "two") {
document.getElementById("process2").style.display = "none";
document.getElementById("process3").style.display = "none"; document.getElementById("process").style.display = "block";
document.getElementById("process1").style.display = "block"; } } } 2.” ClientSideOnClick”- Fires when mouse click on menu items. Code snippet: <ej:Menu ID="Menu1" MenuType="ContextMenu" ClientSideOnClick="onclick" OpenOnClick="false" runat="server" ContextMenuTarget="#Diagram1">
</ej:Menu> function onclick(args) { switch (args.text) { case "process": //some process; break; case "process1": //some process; break; case "process2": //some process; break; case "process3": //some process; break; }
} |
Please let me know if any concerns.
Regards,
Shyam G
Hi Jim
Thanks for the update.
Please note that Node gets selected only on the left click and it will not be selected on the right click. We consider “Node is not selected, when we right click on the node” as a defect and created a new incident 133287 on behalf of you related to this forum. We suggest you to follow up the incident for further reference using your direct trac account
Please let me know if any concerns.
Regards,
Shyam G
Here's my relevant code snippets (primarily what you provided me):
The ejDiagram declaration:
<ej:Diagram ID="DiagramContent" runat="server" Height="100%" Width="100%" ClientDrop="dropHandler" OnClientNodeCollectionChange="nodecollectionchangeHandler"
OnClientSelectionChange="selectionChangeHandler" ClientItemClick="clickHandler" >
</ej:Diagram>
Within $(window).load(function():
var contextMenu = $.extend(true, {}, diagram.model.contextMenu);
contextMenu.items.push({ name: "taskDetails", text: "Details" }, { name: "taskRoles", text: "Roles" }, { name: "taskDataSpecs", text: "Data Specs" });
$("#DiagramContent").ejDiagram({ contextMenu: contextMenu });
ej.datavisualization.Diagram.Locale["en-US"] = {
cut: "Cut",
copy: "Copy",
paste: "Paste",
selectAll: "SelectAll",
taskDetails: "Details",
taskRoles: "Roles",
taskDataSpecs: "Data Specs"
}
The ClientItemClick handler:
function clickHandler(args) {
var diagramId = "DiagramContent";
var node = diagram.selectionList[0];
if (node) {
if (node.addInfo.NodeType) {
if (node.addInfo.NodeType == "Task") {
document.getElementById(diagramId + "_contextMenu_taskDetails").style.display = "block";
document.getElementById(diagramId + "_contextMenu_taskRoles").style.display = "block";
document.getElementById(diagramId + "_contextMenu_taskDataSpecs").style.display = "block";
} else {
document.getElementById(diagramId + "_contextMenu_taskDetails").style.display = "none";
document.getElementById(diagramId + "_contextMenu_taskRoles").style.display = "none";
document.getElementById(diagramId + "_contextMenu_taskDataSpecs").style.display = "none";
}
}
}
}
Any idea what I'm doing wrong?
Are the duplicate context menu items (which you've acknowledged as a defect) getting in my way?
This is a rather serious issue that we would like to address as soon as possible.
Thanks in advance.
Jim
Hi Jim
Thanks for using Syncfusion products.
Query |
Response |
|
We have created a sample of custom context menu and it is available in the below link for download. Please refer the code snippet below.
Code snippet: <script> ej.datavisualization.Diagram.Locale["en-US"] = { taskDetails: "Details", taskRoles: "Roles", taskDataSpecs: "Data Specs" }
var diagramId = "Diagram1"; $(window).load(function () { $("#Diagram1").ejDiagram({ //menu item click event contextMenuClick: "menuClick", //custom context menu contextMenu: { items: [ { name: "taskDetails", text: "Details" }, { name: "taskRoles", text: "Roles" }, { name: "taskDataSpecs", text: "Data Specs" }], }, }); });
function menuClick(args) { alert("menu item clicked"); } </script> Sample:http://www.syncfusion.com/downloads/support/directtrac/117513/customcontextmenusample1252285101.zip |
It seems that I have to right-click on a node twice to see the context menu (the first right click simply selects the node) |
Please note that when node is not selected, then it will be selected on the first right click and it shows the context menu only on the second right click. If the node is selected, then the context menu will be shown on the first right click. This is the default behavior of our diagram control. |
Please let me know if any concerns.
Regards,
Shyam G
Hi Jim,
Thanks for your update.
We are working on this with high priority and we will update you with more information in one business day on 11th March 2015.
Regards,
Ashok Kumar.
Hi Jim
Thanks for your patience
We suggest you to set Model property “EnableContextMenu” as false in order to resolve your reported issue. We have created a simple sample and it is available in the below link for download.
Sample:http://www.syncfusion.com/downloads/support/directtrac/117513/contextmenu-1620889100.zip
Please let me know if any concerns.
Regards,
Shyam G
Hi Jim
Thanks for the update.
We are afraid that we are unable to reproduce the reported issue at our end. Could you please provide us more details such as screenshot or video or modify the below sample to reproduce the reported issue at our end? This will help us to verify further and provide a better solution.
Here is the sample
Sample:http://www.syncfusion.com/downloads/support/directtrac/117513/contextmenu1-2030961451.zip
Here is the video
Video:http://www.syncfusion.com/downloads/support/directtrac/117513/contextmenuvideo1938265962.zip
Note: Please note that we could not find any screenshots from your previous update.
Please let me know if any concerns.
Regards,
Shyam G
Hi Jim
Thanks for the update.
Could you please confirm whether your mean the context menu is repeated twice after performing save and load the diagram? If yes, we are unable to reproduce the reported issue at our end. Could you please provide us more details such as video or modify the below sample to reproduce the reported issue at our end? This will help us to verify further and provide a better solution to you. Please refer the below sample and video below for further reference.
Here is the sample
Sample:http://www.syncfusion.com/downloads/support/directtrac/117513/contextmenusaveandload-732158269.zip
Here is the video
Video:http://www.syncfusion.com/downloads/support/directtrac/117513/contextmenuvideo-883618517.zip
Please let me know if any concerns.
Regards,
Shyam G