您好,将我之前给您的demo中的click事件换成mousemove事件即可。这里绑定的事件都是js的源生事件。代码参考:
- spread.getHost().addEventListener('mousemove', function(e){
- var spreadOffset = $(spread.getHost()).offset();
- var x = e.pageX - spreadOffset.left;
- var y = e.pageY - spreadOffset.top;
- var result = spread.hitTest(x, y);
-
- if (result && result.worksheetHitInfo) {
- var worksheetHitInfo = result.worksheetHitInfo;
- var row = worksheetHitInfo.row;
- var col = worksheetHitInfo.col;
- var cellType = sheet.getCellType(row,col);
- var cellRect = sheet.getCellRect(row, col);
- if(cellType instanceof myCellType){
- $("#validview").css({ left: cellRect.x+cellRect.width, top: cellRect.y+cellRect.height});
- $("#validview").show();
- }else{
- $("#validview").hide();
- }
- }else{
- $("#validview").hide();
- }
-
- });
复制代码
|