Detect cell value change in FlexSheet

Posted by: holly.anderson on 28 December 2017, 12:00 am EST

    • Post Options:
    • Link

    Posted 28 December 2017, 12:00 am EST

    Hello,

    I’m trying to determine the best way to detect when a cell’s value changes in FlexSheet. I’ve seen examples on how to do this within the cellEditEnding event, but that doesn’t cover the case when a cell’s value is changed via paste. It seems unnecessarily redundant to have the same logic for cellEditEnding and pastingCell to cover these two scenarios. Is there a different way to handle this?

    Thanks,

    Holly

  • Posted 28 December 2017, 9:10 pm EST

    Hi Holly,

    You may track edit Changes in FlexSheet using CollectionView itemsEdited by setting trackChanges for CollectionView.

    Please refer to the attached sample for the same.

    ~Manish

  • Posted 28 December 2017, 9:10 pm EST

  • Posted 30 December 2017, 6:11 am EST

    Hi Manish,

    Thanks for the sample. I have a couple questions about tracking changes this way.

    1. If I edit a cell value and then move to another cell in that row, the collectionChanged event handler is not triggered. If I manually edit a cell, it seems like the event only fires when I move to a new row. Note that this is not the case when pasting data. Is there some way to detect changes per cell instead of per row?

    2. Because the event data for collectionChanged contains the entire item/row, how would you determine which property values changed? In other words, I need some way to know which column/cell was edited within the row.

    Thanks,

    Holly

  • Posted 1 January 2018, 4:58 pm EST

    Hi Holly,

    Yeah, you are correct, the collectionChanged event gets triggered once the commitEdit method get called on rowChanged. Same action will be occured with pasting.

    Yeah, itemsEdited array return complete object. If you would like to record changes for each cell, you need to use an array and define a function for getting changes on cellEditEnding and pastedCell event.

    Please refer to the following fiddle for the same:

    http://jsfiddle.net/mkgupta911/xkzdkmsp/8/

    ~Manish

  • Posted 9 January 2018, 3:38 am EST

    Hi Manish,

    If I change a value in the Country column to “US”, it marks it as changed even if the value was previously “US”. I’m looking for a way to detect if the cell value actually changed. In my scenario, I wouldn’t consider “US” to “US” a change.

    If I wanted to compare the old and new values, would I have to do something on pastingCell instead of pastedCell?

    Thanks,

    Holly

  • Posted 9 January 2018, 8:13 pm EST

    Hi Holly,

    Yes, for this you need to handle pastingCell event and check if cell value and pasted data is not same.

    Please refer to the fiddle for the same.

    http://jsfiddle.net/mkgupta911/xkzdkmsp/10/

    ~Manish

Need extra support?

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

Learn More

Forum Channels