How do I pass event info from cell to context menu?

Question 1:
How do I pass event info from cell to context menu? I’ve added a dhtmlxmenu context menu to the scheduler and I’d like it to open a lightbox the same way that a double click on a scheduler cell opens a lightbox. At the moment, the onclick event of the context menu fires, but no event info is passed, so the lightbox does not use the event as a parameter.


// Create a context menu
var myContextMenu1;
function createContextMenu() {
    myContextMenu1 = new dhtmlXMenuObject({
        parent: "contextZone_A",
        context: true
    myContextMenu1.addNewChild(myContextMenu1.topId, 0, "addreservation", "Add Reservation", false);
    myContextMenu1.addNewChild(myContextMenu1.topId, 1, "quotereservation", "Quote Reservation", false);
    myContextMenu1.addNewChild(myContextMenu1.topId, 2, "addmaintenancebooking", "Add Maintenance Booking", false);
    myContextMenu1.addNewChild(myContextMenu1.topId, 3, "addpencilbooking", "Add Pencil Booking", false);
    myContextMenu1.addNewChild(myContextMenu1.topId, 4, "exit", "Exit", false);

    // Createa an event to fire when the user clicks the left mouse button on an ebaled, not complex menu item
    myContextMenu1.attachEvent("onClick", function (id, zoneId, cas) {
        alert("Action: " + id);

        // Add an event for this cell and open the lightbox

        // your code here
        // ...

        // cas example
        if (cas.ctrl == true) {
            // open in a new tab
        } else {
            // open on the same page

Question 2:
How do I set the area of the context menu to be just the children cells of the scheduler, not the entire scheduler? At the moment, I have set a zone for the context menu as the entire scheduler.


<div class="scheduler_container" id="contextZone_A" style="width: 100%; height: 900px; border 1px solid #aeaeae;">

Q1: You can show a context menu manually, using onContextMenu event of the client-side scheduler … event.html … xMenu.html

In this case, you can pass all needed data by saving it in the variable in common scope of onContextMenu and onClick events of a context menu,

[code]//shared variable
var event_id = null;

scheduler.attachEvent(“onContextMenu”, function (id, e){
// save info when context menu called
event_id = id;

//show context menu

myContextMenu1.attachEvent(“onClick”, function (control_id, zoneId, cas) {
alert("Action: " + id);
// get value when it’s needed
alert(“Event id:” + event_id );

event_id = null;
Also you’ll be able to inspect section info in onContextMenu handler and show the menu only when it’s needed … ndata.html

Thanks for your reply.

I almost have the context menu working exactly the way I need it to be, only a couple more things that need to be ironed out.

  1. How do I keep the scheduler page up to date once I’ve added a new reservation? When I right click on a newly created event, and the oncontextmenu event fires up, the id parameter is null:
scheduler.attachEvent("onContextMenu", function (id, e) {
    //shared variable
    event_id = id;

    // Get the action data
    var action_data = scheduler.getActionData(e);

    // Get the section info and only display context menu if in a cell area
    var section = action_data.section;
    var foundCategory = section.indexOf('category');
    var foundSpecialEvent = section.indexOf('specialevent')

    if (section != null && foundCategory === -1 && foundSpecialEvent === -1)
        if (id != null) {
            createContextMenuForFullEvent(id, e);
        else {
            createContextMenuForEmptyEvent(id, e);
    else if (section != null && foundCategory === -1 && foundSpecialEvent === 0)
        createContextMenuForSpecialEvent(id, e);


I currently have a dummy Save() method on the controller that doesn’t perform any actions, and the dxheventshelper.update() method is commented out:

public ContentResult Save(int? id, FormCollection actionValues) ... //DHXEventsHelper.Update(eventToUpdate, changedEvent, new List<string>() { "id" });

  1. How do I get the context menu to only fire when it is called from a cell that is inside dhx_matrix_line, but not fire when it is called from inside dhx_scell_name. At the moment, when I right click every item on the row, the context menu is displayed.

Any ideas on how to solve this problem, please?