Posted 5 September 2023, 9:25 pm EST - Updated 5 September 2023, 9:27 pm EST
Hi. I am using SpreadJS 14. I am trying to write a utility that captures and audits user edits on a spreadsheet - by binding to various eventypes like this:
spread.bind( GC.Spread.Sheets.Events.CellChanged, function ( e, args ) {
if ( args.sheetArea === GC.Spread.Sheets.SheetArea.viewport ) {
if ( args.propertyName === 'value' || args.propertyName === 'formula' ) {
// Capture before and after values
let cellRange = getA1CoordsCell( args.sheet, args.row, args.col );
let operation = args.propertyName === 'value' ? 'Value changed' : 'Formula changed';
let oldValue = args.oldValue;
let newValue = args.newValue;
spreadsheeteditor.addDynamicAudit( operation, args.sheetName, cellRange, oldValue, newValue );
}
}
} );
My challenge (and question) is: how might I do something similar to trap when a user clears a cell using the delete button on their keyboard (i.e. without activating the cell)? Through trial and error, I have found that a “RangeChanged” event is triggered (which is fine) BUT how can I find out the value of the cell prior to it getting cleared (so I can audit the “oldvalue” and “newvalue”? There doesn’t seem to be a “RangeChanging” event that might give me access to the value before it gets removed.
Any ideas how I might achieve this?
Thanks,
Mark