GC.Spread.Sheets.Events.ValueChanged vs GC.Spread.Sheets.Events.RangeChanged

Posted by: philip.j.garbarino on 21 November 2022, 3:27 am EST

  • Posted 21 November 2022, 3:28 am EST

    I would think that if I wanted to get an event that had all value changes I would use the RangeChangedEvent, but it turns out sometimes the event only goes to ValueChanged. This is causing me to have to register both which causes other issues namely contention. We recently put a 5ms delay in one of the events to prevent this. This seems like a hack, shouldn’t RangeChanged handle all changes? Thanks Phil-

  • Posted 21 November 2022, 11:14 pm EST

    Hi,

    ValueChanged is triggered when the value in the subeditor changes, as the name implies. If you change the value of a cell, for example, ValueChanged is triggered.

    However, RangeChanged is triggered when the action has the potential to change a range. If you change a formula, for example, Range Changed is triggered because it may affect a range of cells. Similarly, because the dragFill operation affects a range, RangeChanged is triggered.

    You could also look for actions that cause the RangeChanged event to be raised.

    RangeChangedActionEnumeration:

    https://www.grapecity.com/spreadjs/api/enums/GC.Spread.Sheets.RangeChangedAction

    When you change the value of a cell from “Value1” to “Value2,” RangeChanged will not be triggered. ValueChanged will be triggered in this case. This is expected behavior and by design.

    I hope this helps to clarify your situation. Please let us know if you require any additional assistance with this matter. We would be delighted to assist you.

    Regards,

    Ankit

  • Posted 22 November 2022, 2:04 pm EST

    Hi Ankit,

    We are facing an issue with Range change event, for example you change the cell value from “Value1” to “Value2,” and value change sometimes registered under rangeChanged event and sometimes it doesn’t.

    When we try to use both event to capture all cell changes in the workbook (Value and range) we are losing the value change that happened on that particular cell due to race condition, both events trying to access the same change and its not working properly. As work around we delayed one of the events,

    But we want to know why this is happening?

    We are using spread JS version 15.0.0

    Getenet,

    Thanks

    JPMC

  • Posted 22 November 2022, 2:43 pm EST

    Hello Getenet,

    I tried the most recent SpreadJS V15.2.5 version, but I was unable to reproduce the problem on my end. Please give the most recent version a try.

    If the problem still exists for you, kindly provide a basic working sample that reproduces the problem. You might also change the sample below that was used for testing and send it to us. Include the steps you took as well.

    Sample: https://jscodemine.grapecity.com/share/F7_ypyU50kOsQzV4KV54fQ/

    Regards,

    Ankit

  • Posted 12 December 2022, 9:39 am EST

    So we can see in you sample, why is =1 in a cell a range change but 1 is a value change?

  • Posted 12 December 2022, 9:45 am EST

    also why is it I get no even if I change say a value of 100 to = 50+50, i get no value change, but it should be range change

  • Posted 12 December 2022, 5:31 pm EST

    Hi Philip,

    When you enter “=1” in a cell, SpreadJS follows the Microsoft Excel policy and treats it as a formula (due to the presence of ‘=’ operator) and therefore RangeChanged Event is fired.

    For the scenario when the value is changed from “100” to “=50+50”, the value of the cell doesn’t change, and therefore the RangeChanged is not triggered. If you want to detect this change, you could use the CellChanged Event and you will get the propertyName as “formula” when “100” is changed to “=50+50”.

    References:

    CellChanged Event: https://www.grapecity.com/spreadjs/api/classes/GC.Spread.Sheets.Events#cellchanged

    Regards,

    Ankit

  • Posted 13 December 2022, 2:10 am EST

    so now we need 3 events with conditions in to make sure we don’t get duplicate events fired. If only 1 event was called for each type of change this would be clean or if range changed always got called it would also be clean. Now we have some pretty messy code to ensure only 1 event is triggered for any type of change

  • Posted 15 December 2022, 5:14 pm EST

    Hi Philip,

    The different events are designed to capture the actions performed and gives the user flexibility to perform different actions. The above-mentioned behavior is expected and is by design.

    If you only want to capture if the user has entered formula or not, you could use the UserFormulaEntered event that occurs only when the user types a formula.

    UserFormulaEntered event: https://www.grapecity.com/spreadjs/api/classes/GC.Spread.Sheets.Events#userformulaentered

    Regards,

    Ankit

Need extra support?

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

Learn More

Forum Channels