2金币
请问一下,我想在同个单元格中设置左边显示文本不可编辑,右边显示按钮可点击,怎么实现?(使用单元格按钮,下面有我写的代码)
style = new GC.Spread.Sheets.Style();
//style.locked = false;
style.cellButtons = [
{
imageType: GC.Spread.Sheets.ButtonImageType.search,
caption: "search",
useButtonStyle: true,
enabled: true,
command: (sheet, row, col, option) => {
if (sheet.zoom() === 1) {
sheet.zoom(1.5);
} else {
sheet.zoom(1);
}
}
}
];
sheet.setText(9, 0, "command");
sheet.setStyle(9, 1, style);
sheet.setText(9, 1, "command");
sheet.options.isProtected = true;
|
最佳答案
查看完整内容
单元格不可编辑需要设置表单保护,不过设置表单保护后单元格按钮就不能点击了。
有个思路是: 可以监听 EditStarting 事件,设置以下代码。
sheet.bind(GC.Spread.Sheets.Events.EditStarting, function (sender, args) {
//判断单元格是否有 单元格按钮,如果有则执行:args.cancel = true;
if() {
args.cancel = true;
}
}
|