Custom formula recalculates after insertion/deletion of a row

Posted by: razeris563 on 3 November 2021, 9:14 pm EST

  • Posted 3 November 2021, 9:14 pm EST

    Hey guys!

    I have a custom formula which works without parameters and gets a number depending on the value in first cell of the same row. Whenever I insert/delete a row, every cell that is underneath this row that has this custom formula, recalculates. If I insert a row under the cells that include this formula, they don’t recalculate.

    Also, if I already inserted 1 row, then afterwards the formulas don’t recalculate anymore if I keep inserting/deleting new rows, but if I delete the newly added rows so that the amount of rows is the same as in the beginning, the formulas recalculate again.

    I have tried commenting out everything I have in the following events that are being triggered (rangeChanged, rowChanged) and other possible problematic code but it still does this.

    Thank you a ton for the answer!

    PS: In the attached video, you can see the recalculate happening while flickering between loaded data and 'Loading...' as a default value.
  • Replied 3 November 2021, 10:12 pm EST

    I wasn't able to post the video directly in the post, so here's the link for visualization of this unexpected behavior: https://streamable.com/kvtk70
  • Marked as Answer

    Replied 7 November 2021, 8:07 pm EST

    Hi,

    This is expected behavior spread. SpreadJS recalculates the cells on insertion and deletion of rows if it affects the cell.

    What happens here is when we insert rows above that cell actually the row index is now changed also all rows are shifted down that is why it recalculates all rows below the inserted or deleted.

    I hope that helps!

    Regards
    Avinash
  • Replied 9 November 2021, 8:48 pm EST

    avinash.pathak said:
    Hi,

    This is expected behavior spread. SpreadJS recalculates the cells on insertion and deletion of rows if it affects the cell.

    What happens here is when we insert rows above that cell actually the row index is now changed also all rows are shifted down that is why it recalculates all rows below the inserted or deleted.

    I hope that helps!

    Regards
    Avinash


    Great! Thank you a lot for the answer Avinash, can I just ask one more thing? Why does it not recalculate if i delete a row that I just added, but if i delete another row after adding a row it does recalculate. Hopefully you can explain this to me.
  • Replied 11 November 2021, 6:30 pm EST

    Hi,

    The function should recalculate, also for deleting rows. We tested the functionality at our end it gets recalculated for both insert/delete. Please refer to the following sample and if the issue persists please modify the sample to replicate the issue so that we could investigate it further and help you accordingly.

    sample:https://jscodemine.grapecity.com/share/Dj1gIbOL8E_thLAEzz-ZWQ/

    Regards
    Avinash
Need extra support?

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

Learn More

Forum Channels