您好,请您参考一下以下代码看能否解决您的问题:
- let newCommand = GC.Spread.Sheets.Designer.getCommand(
- GC.Spread.Sheets.Designer.CommandNames.DeleteDialog
- );
- if (newCommand) {
- let oldExecute = newCommand.execute;
- newCommand.execute = function (context, propertyName, args) {
- let activeSheet = context.getWorkbook().getActiveSheet();
- if (activeSheet.getRowCount() < 10) {
- alert("not allow");
- } else {
- oldExecute.call(this, context, propertyName, args);
- }
- };
- }
- designerConfig.commandMap = {};
- designerConfig.commandMap[
- GC.Spread.Sheets.Designer.CommandNames.DeleteDialog
- ] = newCommand;
- let newCommand2 = GC.Spread.Sheets.Designer.getCommand(
- GC.Spread.Sheets.Designer.CommandNames.InsertDialog
- );
- if (newCommand2) {
- let oldExecute = newCommand2.execute;
- newCommand2.execute = function (context, propertyName, args) {
- let activeSheet = context.getWorkbook().getActiveSheet();
- if (activeSheet.getRowCount() > 10) {
- alert("not allow");
- } else {
- oldExecute.call(this, context, propertyName, args);
- }
- };
- }
- designerConfig.commandMap = {};
- designerConfig.commandMap[
- GC.Spread.Sheets.Designer.CommandNames.InsertDialog
- ] = newCommand2;
复制代码
DeleteDialog用于监听删除,InsertDialog用于监听插入。 |