找回密码
 立即注册

QQ登录

只需一步,快速开始

jyjc 讲师达人认证
高级会员   /  发表于:2021-7-29 21:14  /   查看:2020  /  回复:1
使用delete后通过ctrl+z撤销,使用rangechange方法监听不到,目前是通过EUa获取到的区域,请问一下有没有其他的方法获取到该区域
commandManager.register('tabCmdDel', {
                canUndo: true,
                execute: function (context, options, isUndo) {
                    var Commands = $3rd.spreadJS.Sheets.Commands
                    options.cmd = "tabCmdDel"


                    if (isUndo) {
                        Commands.undoTransaction(context, options)
                        var activeSheet = StaticData.spread.getActiveSheet()
                        var sheetName = activeSheet.name()
                        var data = options['changes' + sheetName]
                        var eua = (data.EUa || []).reduce(function (calc, item) {
                            var val = item.value
                            if(!calc.some(function (c) { return c.row === val.row && c.col === val.col })){
                                calc.push({ row: val.row, col: val.col })
                            }
                            return calc
                        }, [])
                        StaticData.spread.suspendPaint()
                        for(var i = 0; i < eua.length; i ++){
                            var row = eua.row
                            var col = eua.col
                            me.handleCellValueChange({
                                row: row,
                                col: col,
                                value: activeSheet.getValue(row, col)
                            })
                        }
                        StaticData.spread.resumePaint()
                        return true
                    } else {
                        Commands.startTransaction(context, options)
                        valueChange(function (activeSheet,rowIndex, colIndex) {
                            activeSheet.setValue(rowIndex, colIndex, null)
                        })
                        Commands.endTransaction(context, options)
                        return true
                    }
                }
            })


1 个回复

倒序浏览
Derrick.Jiao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2021-7-30 11:19:44
沙发
我这边用rangechanged是可以监听用delete删除后再撤销的区域的,下面红框就是撤销后的区域。 image.png20816039.png
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部