SpreadJS Documentation > Sample Code > Sample Code for Cells > Getting Header Cell Index from Mouse Click |
You can get the index of the header cell when selecting it with the mouse.
This example gets the index for the header cell.
JavaScript |
Copy Code
|
---|---|
$("#ss").click(function (e) { // Acquire cell index from the mouse-clicked point of column header cells. var offset = $("#ss").offset(); var x = e.pageX - offset.left; var y = e.pageY - offset.top; var target = $("#ss").data("spread").getActiveSheet().hitTest(x, y); if(target && target.rowViewportIndex === -1 && (target.colViewportIndex === 0 || target.colViewportIndex === 1)){ console.log("Row index of mouse-clicked column header cells: " + target.row); console.log("Column index of mouse-clicked column header cells: " + target.col); } }); |