3.2.0

How to properly set oncontextmenu event on rows

I have tried the following to set an action to the oncontextmenu event of the selected row:
unction oncontextmenu(event){
    this.raiseEvent("onRowContextMenu");
}

// assign html event handler to row template
obj.getRowTemplate().setEvent("oncontextmenu", oncontextmenu);


// assign grid event handler
obj.onRowContextMenu = function(event, index){
    alert("myData["+index+"][0] = " + myData[index][0]);
}


But in Firefox I get the error this.raiseEvent is not a function.

Is there another way to set the action, perhaps something like....
obj.getRowTemplate().setEvent("oncontextmenu", function (event, src) 
{
...
}
);
Neil Craig
March 22,
Here is an example of row context menu handler -

// html event handler translates to grid events
    function oncontextmenu(event){
        this.raiseEvent("onRowContextMenu");
    }

    // assign html event handler to row template
    obj.getRowTemplate().setEvent("oncontextmenu", oncontextmenu);


    // assign grid event handler
    obj.onRowContextMenu = function(event, row){
        alert(row);
    }
Alex (ActiveWidgets)
March 22,
The code

function oncontextmenu(event){
    this.raiseEvent("onRowContextMenu");
}


still gives an error in FF but at least it is working in IE6
Neil Craig
June 6,
What does this raisEvent method do?
Neil Craig
June 6,
Finally I found what was wrong here - it looks like firefox thinks that function oncontextmenu(event){..} is an event handler attached to the window object, so it is called for the grid row (as intended) AND for the window object (which does not have custom AW raiseEvent method). So the solution is simply to rename the event handler. This code now works ok -

// html event handler translates to grid events
    function raiseMenuEvent(event){
        this.raiseEvent("onRowContextMenu");
    }

    // assign html event handler to row template
    obj.getRowTemplate().setEvent("oncontextmenu", raiseMenuEvent);


    // assign grid event handler
    obj.onRowContextMenu = function(event, row){
        alert(row);
    }
Alex (ActiveWidgets)
June 7,
It seems that the event parameter (onRowContextMenu) is undefined. When I tried to access the clientX property, the browser returned 'undefined'.

How could I use the above examples to implement the Context Menu Script (http://www.activewidgets.com/javascript.forum.14415.0/context-menu-script.html) I have posted on this site?
Neil Craig
June 7,
Oops, sorry, it should be -

// html event handler translates to grid events
    function raiseMenuEvent(event){
        this.raiseEvent("onRowContextMenu", event, this.$0);
    }

    // assign html event handler to row template
    obj.getRowTemplate().setEvent("oncontextmenu", raiseMenuEvent);


    // assign grid event handler
    obj.onRowContextMenu = function(event, row){
        alert("row=" + row + " x=" + event.clientX + " y=" + event.clientY);
    }
Alex (ActiveWidgets)
June 7,
Thanks Alex!

I have bookmarked this thread for future reference.
Neil Craig
June 7,

This topic is archived.

See also:


Back to support forum