:: Forum >>

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
Wednesday, March 22, 2006
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)
Wednesday, March 22, 2006
The code

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


still gives an error in FF but at least it is working in IE6
Neil Craig
Tuesday, June 6, 2006
What does this raisEvent method do?
Neil Craig
Tuesday, June 6, 2006
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)
Wednesday, June 7, 2006
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
Wednesday, June 7, 2006
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)
Wednesday, June 7, 2006
Thanks Alex!

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

This topic is archived.


Back to support forum

Forum search