undoTransaction options changesSheetname property means?

Posted by: 122368177 on 15 April 2020, 5:05 am EST

  • Posted 15 April 2020, 5:05 am EST

    Code:

    registerAddSpan() {

    const command = {

    canUndo: true,

    canRedo: true,

    execute: (

    workbook: GC.Spread.Sheets.Workbook,

    options: any,

    isUndo: boolean

    ) => {

    const Commands = GC.Spread.Sheets.Commands

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

    console.log(JSON.stringify(options.changesSheet2))

    if (isUndo) {

    Commands.undoTransaction(workbook, options)

    this.emit(‘removeSpan’, {

    sheet,

    sheetName,

    row,

    col

    })

    return true

    } else {

    Commands.startTransaction(workbook, options)

    sheet.addSpan(

    row,

    col,

    rowCount,

    colCount,

    GC.Spread.Sheets.SheetArea.viewport

    )

    this.emit(‘addSpan’, {

    sheet,

    sheetName,

    row,

    col,

    rowCount,

    colCount

    })

    Commands.endTransaction(workbook, options)

    return true

    }

    }

    }

    const cm = this.workbook.commandManager()

    cm.register(‘addSpan’, command)

    }

    my sheetName is ‘Sheet2’,and do undo operation get

    options.changesSheet2 = [[[“spanModels”,3,“spans”],],[[“selectionModel”,“selections”],[{“row”:1,“rowCount”:2,“col”:3,“colCount”:2}]],[[“selectionModel”,“activeSelectedRangeIndex”],0]]

    how do I use the data to do removeSpan or tell the other people which span I need to remove.

    I don’t know how to handle removeSpan .I hope get a event like rangeChanged event to handle undo .And if spans has A span between B span,How do I handle the removeSpan, becase removeSpan just has row,col without rowCount colCount

    How to use commandManager emit DragMerged events. Also it can solve my problem.

    Thanks again~

  • Posted 15 April 2020, 5:21 am EST

    supplementary instruction:

    First I do addspan() in a small range.

    Next I do addspan() in a large range include small range.

    Lastly I do undo, spreadsheet rollback to small range.

    But I don’t kown what happened ,I would like to know what happened…,now just has row,col,rowCount,colCount and options.changesSheetname. Maybe I can do getSpans() to get current spans~~

  • Posted 15 April 2020, 5:26 am EST

    Another question. How do I handle addspan merge row or col, but not all range

    Thanks a lot

  • Posted 16 April 2020, 10:43 am EST

    Hi,

    how do I use the data to do removeSpan or tell the other people which span I need to remove?

    For removing span from the sheet you just need the first row and first column from where the span just started in your case options.row and options.col will be sufficient to identify which span is removed

    First I do addspan() in a small range:

    Next I do addspan() in a large range include small range.

    Lastly I do undo, spreadsheet rollback to small range.

    when you do undo the undo transaction will be executed and their options object have the row and the column on which the span was there if you want to notify someone that span is removed you just need to send the row index and column index

    How do I handle addspan merge row or col, but not all range

    Could you please more about the requirement, do you mean to merge two rows/columns?

    API Reference:

    removeSpan: https://www.grapecity.com/spreadjs/docs/v13/online/SpreadJS~GC.Spread.Sheets.Worksheet~removeSpan.html?highlight=removespan%2C

    Regards

  • Posted 19 April 2020, 10:26 pm EST

    Thanks for your apply.

    First I do addspan() in a small range:

    notify someone ‘addSpan’ row col. OK~

    Next I do addspan() in a large range include small range.

    notify someone ‘addSpan’ row col OK~

    Lastly I do undo, spreadsheet rollback to small range.

    notify someone ‘removeSpan’ row col . it occurs the diff operation.

    A get the small span. B revert to the original cell state

    Because A has operation undo history. B has not.,just get the command to handle removeSpan. Because browsers maybe is refreshed. it is a reason just to send a removeSpan.otherwise server need to recode the undo.

    Thanks again~

  • Posted 20 April 2020, 3:39 am EST

    In this case, you may use the getSpans() method to get the info about smaller spans that were restored as a result of undo operation. Please refer to the following code snippet:

    if (isUndo) {
        Commands.undoTransaction(workbook, options);
        let newSpans = sheet.getSpans(
              new GC.Spread.Sheets.Range(
                options.row,
                options.col,
                options.rowCount,
                options.colCount
              )
        );
        this.emit('removeSpan', {
            sheet,
            sheetName,
            row,
            col,
            newSpans
        })
        return true;
    }
    
Need extra support?

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

Learn More

Forum Channels