CellChanged event in SpreadJs fires twice?

Posted by: klasmellbournhm on 8 September 2017, 9:43 am EST

  • Posted 8 September 2017, 9:43 am EST

    When I have a databound SpreadJS sheet, and I bind the CellChanged event, then, when I make a change in the grid, the event fires twice.

    The first time the args parameter has the old values. The second time the args parameter has the new values.

    I want only one event, the one with the new parameters. How do I get this?

  • Posted 8 September 2017, 9:43 am EST

    Hello,

    I was able to replicate the issue which you have reported. This one looks like a bug to me and I have escalated it to the developers for review. We will get back to you once an update would be available.

    Regards,

    Sankalp

  • Posted 8 September 2017, 9:43 am EST

    Any news on this?

    Thanks,

    Klas

  • Posted 8 September 2017, 9:43 am EST

    Klas,

    I have got an update on this issue from the developers and as per them this issue is not a bug but the design behavior. CellChanged event will be fired when anything changes in a cell, like style changed, value changed, validator changed and so on.

    If you only want to know when a value changed in the cell then you can use a code like this to make the event fire once:

    [js] spread.bind($.wijmo.wijspread.Events.CellChanged, function (sender, args) {

    if (args.propertyName === “value”) {

    alert(“Event Fired”);

    }

    });[/js]

    Please try this and let me know if this helps.

    Regards,

    Sankalp

  • Posted 8 September 2017, 9:43 am EST

    Yes, that seems to cure our problem. Excellent. Thank you!

  • Posted 23 August 2018, 12:11 pm EST

    Thanks everyone.

    sankalps, can you elaborate on why the default behavior for cellChanged is to fire twice? I was able to get it to fire just once with your example - but what’s the normal usage for having this fire twice? Just wondering the purpose of the second event trigger is, and what you would normally do with it.

    I’m using Angular, so in my component, my alert fires twice:

      cellChanged (args) {
          alert("Cell changed!");
        }
    

    To fire once I used

      cellChanged (args) {
        if (args.propertyName === "value") {
          alert("Cell changed!");
        }
      }
    
Need extra support?

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

Learn More

Forum Channels