87,987
社区成员
发帖
与我相关
我的任务
分享$(document).ready(function () {
var spread = new GcSpread.Sheets.Spread($("#ss").get(0), { sheetCount: 1 });
var sheet = spread.getActiveSheet();
sheet.setCellType(0, 0, new MyCheckBoxCellType(), GcSpread.Sheets.SheetArea.colHeader);
});
function MyCheckBoxCellType() {
GcSpread.Sheets.CheckBoxCellType.apply(this);
this.caption("操作");
}
MyCheckBoxCellType.prototype = new GcSpread.Sheets.CheckBoxCellType();
var basePaint = GcSpread.Sheets.CheckBoxCellType.prototype.paint;
MyCheckBoxCellType.prototype.paint = function (ctx, value, x, y, width, height, style, context) {
var tag = context.sheet.getTag(context.row, context.col, context.sheetArea);
if (tag !== true) {
tag = false;
}
basePaint.apply(this, [ctx, tag, x, y, width, height, style, context]);
};
MyCheckBoxCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
if (context) {
return { x: x, y: y, row: context.row, col: context.col, cellRect: cellRect, sheetArea: context.sheetArea, isReservedLocation: true, sheet: context.sheet };
}
return null;
};
MyCheckBoxCellType.prototype.processMouseUp = function (hitInfo) {
var sheet = hitInfo.sheet, row = hitInfo.row, col = hitInfo.col, sheetArea = hitInfo.sheetArea;
var tag = sheet.getTag(row, col, sheetArea);
if (tag === undefined || tag === null) {//first time
sheet.setTag(row, col, true, sheetArea);
} else {
sheet.setTag(row, col, !tag, sheetArea);
}
//add your code here
tag = sheet.getTag(row, col, sheetArea);
var rownum = sheet.getRowCount();
for (let i = 0; i < rownum; i++) {
sheet.setValue(i, 0, tag);
}
};