明白您的意思,但是我们目前没有在切换前触发activeSheet的事件,如果您期望实现这样一个效果,建议监听ActiveSheetChanging事件,对所有切换动作都cancel,然后根据弹窗中的确认和取消按钮去主动用代码切换sheet,具体操作如下:
- spread.bind(GC.Spread.Sheets.Events.ActiveSheetChanging, function (sender, args) {
- args.oldSheet.isSelected(true);
- args.newSheet.isSelected(false);
- args.cancel = true;
- document.getElementById('myModal').style.display = 'block';
- document.getElementById('confirmBtn').addEventListener('click', function () {
- document.getElementById('myModal').style.display = 'none';
- spread.setActiveSheet(args.newSheet.name());
- spread.repaint()
- }, { once: true });
- document.getElementById('cancelBtn').addEventListener('click', function () {
- document.getElementById('myModal').style.display = 'none';
- }, { once: true }); // { once: true } 确保事件处理程序只执行一次
- });
复制代码
|