Posted 10 April 2020, 5:43 am EST
Ctrl+Z not work when I edit end.But I use “new GC.Spread.Sheets.Workbook” ,it works
Forums Home / Spread / SpreadJS
Posted by: 122368177 on 10 April 2020, 5:43 am EST
Posted 10 April 2020, 5:43 am EST
Ctrl+Z not work when I edit end.But I use “new GC.Spread.Sheets.Workbook” ,it works
Posted 12 April 2020, 11:07 pm EST
I find problem.
editChange(type: IEventTypeObj, data: GC.Spread.Sheets.IEditChangeEventArgs) {
data.sheet.setValue(
row,
col,
editingText,
GC.Spread.Sheets.SheetArea.viewport
)
}
Undo not work! Because I need to get old value but editing doesn’t return oldEditText,so I have to set value.
Posted 13 April 2020, 9:12 am EST
Hi,
If I understand correctly you want to find the old editor text in EditChange event but currently, only the current edit value is available in the handler for EditChange, since edit change is fired only when the cell value changes in edit mode, the requirement seems a little unusual. Could you please explain about your use case so that we could have a better understanding of the requirement and assist you accordingly.
If you just need to compare the old edited text to the new edited text then I would recommend you to use the EditEnded or CellChanged Event which is fired when the cell value is changed and committed.
API Reference:
EditEnded: https://www.grapecity.com/spreadjs/docs/v13/online/SpreadJS~GC.Spread.Sheets.Events~EditEnded_EV.html
CellChanged: https://www.grapecity.com/spreadjs/docs/v13/online/SpreadJS~GC.Spread.Sheets.Events~CellChanged_EV.html
Regards
Posted 13 April 2020, 9:37 pm EST
Hi,
Old editor text makes comparison with editingText ,I can get the diff textDetail to handle the realtime-collaboration with other people.
Posted 13 April 2020, 9:41 pm EST
I found the way,when I emit enterCell event,I assign current cell value to editCache,
like:
editChange(type: IEventTypeObj, op: GC.Spread.Sheets.IEditChangeEventArgs) {
const newText = editingText
const oldText = this.editTextCache
this.editTextCache = editingText
}
Posted 14 April 2020, 7:17 am EST
For real-time collaboration, you actually don’t need to handle the undo for editChange event. You may simply notify the server about the new editing value, even if you need to display a diff comparison, since edit change is fired when user is still in edit mode, instead of showing the difference between the current editing value and the previous editing value what you should do is show the difference between current editing value and the last committed cell value.
ex: if last committed value of a cell is “lastvalue”, then user enters edit mode and changes value to “newValue” then the difference should be shown as
old value: “lastvalue”
current value: “newvalue”
then if user performs edit while still in edit mode and the editing text becomes “new”, then the difference should be displayed as :
old value: “lastvalue”
current value: “new”
Please let me know if this doesn’t work for your use case.
Posted 14 April 2020, 11:19 pm EST
Thanks a lot