Undo operation

Posted by: 122368177 on 12 April 2020, 11:29 pm EST

  • Posted 12 April 2020, 11:29 pm EST

    I want to bind enterCell、editChange…undo event, whether I have to register custom event with commandManager?

    Like

    const customEnterCell = {

    canUndo: true,

    execute: (

    workbook: GC.Spread.Sheets.Workbook,

    options: any,

    isUndo: boolean

    ) => {

    const Commands = GC.Spread.Sheets.Commands

    const { row, col, sheet, sheetName } = options

    console.log(row, col, isUndo)

    if (isUndo) {

    Commands.undoTransaction(workbook, options)

    // to do undo handle

    return true

    } else {

    Commands.startTransaction(workbook, options)

    this.workbook.focus(true)

    sheet.setActiveCell(row, col)

    this.emit(‘enterCell’, {

    sheet,

    sheetName,

    row,

    col

    })

    Commands.endTransaction(workbook, options)

    return true

    }

    }

    Whether I shouldn’t use spread default events like entercell

    ,userFormulaEntered …

    I need to get undo handle for every operation

  • Posted 13 April 2020, 8:59 am EST

    Hi,

    If I understand correctly you are trying to handle the undo event for enterCell, editChange events. I can confirm that the undo event for these events is not available but I am unable to understand your use case that why you need to handle undo for enterCell, editChange.

    EnterCell event fires when focus enters the cell and editChange fires when the cell is in edit mode and the edit value is changed. Could you please explain your use case that why you need to handle undo for these events so that we could assist you accordingly

    Regards

    Sharad

  • Posted 13 April 2020, 9:48 pm EST

    Hi,

    Realtime-collaboration need to handle the undo event to notify the server.So I have to custom the entercell,editChange

    Could you help me provide a better way.

  • Posted 14 April 2020, 7:07 am EST

    If you building a realtime collaboration then instead of handling the undo and notifying about the server about the undo event, you may simply handle the edit change and inform the server about the current edit value.

    ex: let’s say current editing text is “test1string” but then the user performs undo and then editing text becomes “test1” then instead of notifying that an undo event is performed you may simply inform the server that value is changed to “test1” now.

Need extra support?

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

Learn More

Forum Channels