Event Handler for Right-Click in Subrow?

Is there a way to capture right-click events for subrows of a grid row, thereby being able to either initiate some action (perhaps the same that’s initiated on a right-click on a main row), or return false to ignore the right-click entirely.

dhtmlxGrid doesn’t have such event. But you can use dhtmlEvent object to add any necessary to any container on the page.

dhtmlxEvent("container","dblclick", eventHandler);

That sounds like a workable approach. I assume I’d have to iterate through each subrow, attaching the event to each one’s container. How are the subrow containers identified? I.e., document.getElementById(‘what?’)

While it possible to access those elements by API, it may be a bit more simple solution to include context handler directly in sub-rows content.


My sub row content


I like the suggestion, but how would I include the DIV with the oncontextmenu event handler if the subrow is loaded by XML? Doesn’t the cell have to have the URL of the XML loader? How could both this and the DIV approach you offer coexist?

Silly me… I can just implant the construct into the code that populates the subrow. I tested this and I can, indeeed, execute an oncontextmenu function on right-click in the subrow. Now all I have to do is cancel the event “bubbling” (which, as I recall, requires different code for different browsers).

If one desires to ignore the right-click entirely in the subrow, the following approach appears to work in IE, FF, and Chrome:

<div oncontextmenu='event.returnValue=false;return false'>subrow-content</div>

Or, perhaps more appropriately…

oncontextmenu="try{event.returnValue=false}catch(e){};return false"