How to distinguish RangeChangedAction‘s clear type

Posted by: 122368177 on 30 July 2020, 4:26 am EST

  • Posted 30 July 2020, 4:26 am EST

    
    clearType as GC.Spread.Sheets.StorageType
    sheet.clear(
            row,
            col,
            rowCount,
            colCount,
            GC.Spread.Sheets.SheetArea.viewport,
            clearType
          )
    spread.bind(
          GC.Spread.Sheets.Events.RangeChanged,
          ()=>{
    	const { action, isUndo } = op
    	if(action === 2){
    		// to do clear action,but I can't distinguish clear data or style
    	}
          }
        )
    
    
  • Posted 30 July 2020, 4:40 am EST

    I pressed keyboard shortcut ‘delete’, spread sheet range data has been deleted,

    however I clear style by custom button and need to execute code sheet.clear(…),

    So, I can’t distinguish rangedChanded event action’s clear type to handle diff operation, their action value is same 2

  • Posted 31 July 2020, 9:46 am EST

    Hi,

    If I understand correctly you want to check changes made by your custom button in this case you may create your own flag and check inside the Events please refer to the following code snippet and attached sample which demonstrates the same.

    
      spread.bind(GC.Spread.Sheets.Events.RangeChanged, (e, args) => {
        if (flags.styleCleared) {
          alert("styleCleared");
          flags.styleCleared = false;
        }
      });
    
    document.getElementById("clear").addEventListener("click", () => {
      flags.styleCleared = true;
      let sel = spread.getActiveSheet().getSelections()[0];
      spread
        .getActiveSheet()
        .clear(
          sel.row,
          sel.col,
          sel.rowCount,
          sel.colCount,
          GC.Spread.Sheets.SheetArea.viewport,
          GC.Spread.Sheets.StorageType.style
        );
    });
    

    sample: https://codesandbox.io/s/spread-js-starter-5m88c

    Regards

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels