SpreadJS detect delete 1 cell or multiple cells

Posted by: duynb9596 on 23 November 2021, 12:49 pm EST

  • Posted 23 November 2021, 12:49 pm EST

    Good morning,

    I'm currently searching for an event or some ways to detect when a cell or multiple cells are deleted on SpreadJS, I've used GC.Spread.Sheets.Events.ColumnsChanged and GC.Spread.Sheets.Events.RowsChanged to detect when 1 or multiple rows / columns are deleted from the sheets. Please let me know if there is any possible way to detect when I only delete 1 or multiple random cells on the sheets and then shift up / left the other affected cells.

    Many thanks,
    Duy Nguyen
  • Replied 23 November 2021, 10:10 pm EST

    Hey,

    You can bind the sheet with RangeChangedEvent which occurs when the cell range has changed. Check for the condition when action is 2(clear). For row(s) and col(s) delete, you can bind to ColumnsChanged and RowChanged and check for property name "deleteRows" and "deleteColumns".
    You can listen to shift up / left by using
    spread.commandManager().addListener('appListener', function (args) { console.log(args); });

    Here is a sample: https://jscodemine.grapecity.com/sample/vBMkKs7sFUy-RvtA21IVlA/
    RangeChanged Event: https://www.grapecity.com/spreadjs/docs/v14/online/SpreadJS\~GC.Spread.Sheets.Events\~RangeChanged_EV.html

    RangeChangedAction: https://www.grapecity.com/spreadjs/docs/v14/online/SpreadJS\~GC.Spread.Sheets.RangeChangedAction.html
    Thanks
  • Replied 24 November 2021, 1:47 pm EST

    Good morning,

    I have tried using your suggestion with RangeChangedEvent and addListener('appListener'), but neither of them works for me. When I delete a random cell or an area of cells and then choose option shift left / up, neither the events above could catch the action. I have already used the ColumnsChangedEvent and RowsChangedEvent in my code to catch the action when deleting a whole row(s) / column(s). So, I have tried all 4 of the events you suggested above (RangeChangedEvent, RowsChangedEvent, ColumnsChangedEvent, addListener('appListener') to catch the action when deleting a random cell or an area of cells and then shift the affected cells, and none of them work for me, can you confirm that they work in your codes. Are there any other ways to catch this behavior? Also, the links you gave me above are not accessible with error code 404.

    Many thanks,
    Duy Nguyen
  • Marked as Answer

    Replied 25 November 2021, 2:59 pm EST

    Hi Duy,

    Could you please refer to the following sample and let me know if you still face any issues?

    sample: https://jscodemine.grapecity.com/share/qCxIKKt2xUSHHFFbVHC6Hw/

    Regards,
    Avinash
  • Replied 25 November 2021, 3:54 pm EST

    Dear Avinash,

    Thank you very much! I have finally made it works. The problem earlier with my code was that I bound 'appListener' event to spreadHost (as the other listnener events in my codes), so it couldn't work. This topic is now closed as the problems have been resolved.

    Regard,
    Duy Nguyen
Need extra support?

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

Learn More

Forum Channels