回复 1楼luozhu1986的帖子
有CellClick事件,当鼠标点击单元格的时候触发此事件。
参考代码:
Javascript (Usage)
- var instance; // Type: Events
- instance.CellClick = function(sheet, sheetName, sheetArea, row, col) { };
复制代码
Javascript (Specification)
- CellClick = function (
- sheet : Sheet,
- sheetName : string,
- sheetArea : SheetArea,
- row : number,
- col : number
- ) { };
复制代码
另外可以通过hitTest方法获取鼠标点击单元格的点,从而得到单元格的index。
JavaScript:
- //Acquire cell index from mouse-clicked point of regular cells which are neither fixed rows/columns nor row/column headers.
- var offset = $("#ss").offset();
- var x = e.pageX - offset.left;
- var y = e.pageY - offset.top;
- var target = $("#ss").wijspread("spread").getActiveSheet().hitTest(x, y);
- if(target &&
- (target.rowViewportIndex === 0 || target.rowViewportIndex === 1) &&
- (target.colViewportIndex === 0 || target.colViewportIndex === 1)){
- console.log("Row index of mouse-clicked cells: " + target.row);
- console.log("Column index of mouse-clicked cells: " + target.col);
- }
复制代码 |