Reputation: 1
Is there a way to accurately determine the x,y coordinates of the cursor within the viewable area of the tabulator? I've wired up a third party context-menu control to display when the user right click's on a given cell in a row. I'm using the property e.currentTarget.offsetLeft on the cell right-click event which appears to (more or less) place the menu on screen where I want it relative to the left side of the tabulator. It's the vertical/Y positioning that I'm struggling with because as soon as I scroll down several pages of tabulator data the menu vanishes. I thought that using e.currentTarget.offsetParent.offsetTop would solve this issue, but it doesn't. I'm using Tabulator v3.5. Can anyone help? Cheers.
Upvotes: 0
Views: 178
Reputation: 8368
If you upgrade to version 4.6 it comes with built in Context Menus
//define row context menu
var cellContextMenu = [
{
label:"Reset Value",
action:function(e, cell){
cell.setValue("");
}
},
]
//add header menu in column definition
var table = new Tabulator("#example-table", {
columns:[
{title:"Name", field:"name", width:200, contextMenu:cellContextMenu}, //add a context menu to the cells in this column
]
});
If you are concerned about jQuery and version4.x there is a jQuery Wrapper that makes the transition easy. There is also a detailed [Upgrade Guide}, most sites take a matter of minutes to a couple of hours to upgrade depending on complexity
Upvotes: 0