How to insert multi rows at once and support undo in Flexgrid

Posted by: 1071118072 on 31 October 2024, 5:16 am EST

    • Post Options:
    • Link

    Posted 31 October 2024, 5:16 am EST

    I want to insert multi grid rows in code at once, but I do not kown how to let the undostack works.

  • Posted 31 October 2024, 7:25 am EST

    Hello,

    You can invoke the onRowAdded method of MultiRow after dynamically adding a row through code. This will automatically add an undoable action to the undo stack. Here’s a sample for your reference:

    https://stackblitz.com/edit/angular-ossv8s?file=src%2Fapp%2Fapp.component.html,src%2Fapp%2Fapp.component.ts

    Additionally, you can check out the Wijmo demo sample for the undo stack, which demonstrates how to add an undoable action when adding or deleting rows through code. You can apply a similar approach with MultiRow. If you face any issues, please let us know!

    Demo link: https://developer.mescius.com/wijmo/demos/Undo/UndoStack/angular

    Regards

  • Posted 31 October 2024, 1:11 pm EST

    I know that invoking the onRowAdded method works well when insert one row in code. If I insert 100 rows at once in code and invoke onRowAdded 100 times at same time, I need undo 100 times to go back. So, how to go back by undoing once only ?

  • Posted 4 November 2024, 8:09 am EST

    Hi,

    For now, undo/redo operations for adding multiple rows at once in the grid is not supported. We are looking for a workaround for you, if possible. We will share an update with you soon.

    Regards

  • Posted 4 November 2024, 12:28 pm EST

    OK. Thank you !

  • Posted 5 November 2024, 5:55 am EST

    Hi,

    You can create a custom Undoable Action for adding multiple rows by extending the ‘UndoableAction’ class and pushing it to the stack manually when multiple rows are added to the grid. Here’s a sample for your reference - https://stackblitz.com/edit/angular-5wbmme?file=src%2Fapp%2Fapp.component.ts

    In case, if there is something we missed, please let us know.

    Regards

  • Posted 6 November 2024, 9:03 pm EST

    It works well in latest version. But my version is 5.20211.794, there is no _focusScroll method in UndoableAction class. How to deal with it ?

  • Posted 7 November 2024, 3:27 am EST

    Hi,

    It seems the ‘_focusScroll’ method was added in a newer version of Wijmo. To avoid any issues you can use ‘this._target.focus();’ instead of ‘this_focusScroll();’ in your code.

    Here’s an updated sample with Wijmo version 5.20211.794 for your reference - https://stackblitz.com/edit/angular-djrsu8?file=src%2Fapp%2Fapp.component.ts

    In case, you still face any issues, please let us know.

    Regards

  • Posted 7 November 2024, 4:42 am EST

    It works. Thank you very much !

Need extra support?

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

Learn More

Forum Channels