SpreadJs Event Trigger Issues

Posted by: c1_jonc on 8 September 2017, 9:47 am EST

  • Posted 8 September 2017, 9:47 am EST

    I am having a number of issues with the triggers for spread js, some of which I found in the forums as known issues with no status update for over a month.

    Problem 1

    When I have a cell with a formula in it and make a change to a cell, the cells which change as a result do not fire off the ValueChanged or CellChanged events. I know this has been reported previously here (and in a link referenced there as well)

    http://wijmo.com/topic/formula-change-event/

    but I have not seen an update and it still is an issue in the newest release.

    Problem 2

    Hitting the delete key while on a cell does not seem to fire any events. As per this link http://wijmo.com/topic/spreadjs-events/ I tried using the RangeChanged event but it does not fire this event either.

    Problem 3

    As a workaround for the above problem 2 I attempted to add a key map event to capture the pressing of the delete key and setting the value of the cell by calling setValue on the sheet. This even fires as expected, but the setValue method also does not seem to fire off any of the events including CellChanged, RangeChanged or ValueChanged.

    I have included the important parts of the code below, as you can see i have tried all three event types and none of them appear to fire off as I would expect

    [js]

    var _bindEvents = function(sheet) {

    // sheet.bind($.wijmo.wijspread.Events.CellChanged, function (event, cellInfo) {

    sheet.bind($.wijmo.wijspread.Events.RangeChanged, function(event, cellInfo) {

    // sheet.bind($.wijmo.wijspread.Events.ValueChanged, function(event, cellInfo) {

    console.info(‘range changed’);

    console.info(cellInfo);

    self.updateValueIfFound(cellInfo);

    });

    sheet.addKeyMap($.wijmo.wijspread.Key.del, false, false, false, function () {

    console.info(‘delete hit’);

    var sh = self.spreadsheet().getActiveSheet();

    sh.setValue(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex(), ‘’);

    });

    };

            self.bindEvents = function () {
                $.each(self.spreadsheet().sheets, function (index, sh) {
                    _bindEvents(sh);
                });
            };
    

    [/js]

    Any updates and/or work around options would be helpful. Thanks.

  • Posted 8 September 2017, 9:47 am EST

    Hello,

    1. As per the development team, currently SpreadJS does not provides full dirty cell concept. They are planning to add this ability in the future releases of SpreadJS.

    Currently, as a workaround, you could use getDirtyRows and clearPendingChanges method to simulate the desired behaviour. Please see the sample in SpreadJS product package named MVCSample, it is a simple demo which implement interact with database.

    1. I was not able to replicate the issue at my end with the latest version of SpreadJS i.e. 2014v2.12.The RangeChanged event is correctly raised when the user hits the Delete key. Please refer to the attached sample used for testing.

    I would suggest you to test the issue with the latest build of SpreadJS which you can download from the following link. In case the issue still persists, please modify the attached sample to depict your issue so that I can debug the issue further at my end. Please let me know if you are facing this issue specific to any browser.

    1. All the three events, i.e. CellChanged, RangeChanged or ValueChanged are raised only when the end users changes the cell value in the browser window. They are not raised when the cell value is changed through code. This is the expected behaviour of SpreadJS.

    Hope it helps. Please let me know if you have any queries further.

    Thanks,

    Manpreet Kaur

  • Posted 8 September 2017, 9:47 am EST

    Thanks for your response Manpreet,

    1. I am not sure what you mean by using the getDirtyRows method. I see the method but this just returns an array of objects only containing row numbers but no other data. I do not see any clearPendingChanges method anywhere in your documentation. Any additional information would be helpful.

    2. I have attached an example of how the RangeChanged event no longer fires if you add a keymap for the delete key, it seems to override the event. I am not sure if this is intended or not, but I only had added that because a previous version I was working with had an issue with the delete key triggers. In the newest version of the code, the event fires properly when hitting the delete key so I can now just remove the keymap and the RangeChanged event fires correctly.

    3. Is there anyway to force it to call this event when I set the value thru code? I am doing custom validation of data in the cells and if the user inputs bad data I want to be able to notify the user and set the value back to the original value. Since I am only binding to the event changes I never get notified of a change that was set thru code because it failed validation.

    As a work around I changed to use the EditEnding event and run the validation and cancel the change if it failed. This is not as nice of a user experience, however, as the user gets stuck in edit mode until they fix the value and there is nothing on info object passed into the delegate function which says what the previous value was, we only get editingText which is the new text.

    Also, after using a great deal of your events I have noticed one thing that is somewhat frustrating about the RangeChanged event, this appears to be the only event where the info object passed in has a property ‘column’ rather than ‘col’ like all the rest. This is not necessarily bad, but it makes it a bit inconsistent and does not allow us to use these events consistently like an interface.

    Thanks for your help.

  • Posted 8 September 2017, 9:47 am EST

    Hello,

    1. I have requested the concerned team for further elaboration on the suggested method. I would let you know as soon as I get any information in this regard.

    2. The RangeChanged event was raised in all the three browsers namely IE10, FireFox and Google Chrome at my end using the sample provided by you. Please let me know in case you are facing this issue specific to any browser.

    3. Currently, there is no way to raise these events when the cell value is changed through code. However, could you please elaborate the exact use case where in you are changing the cell value through code and needs the validation to be performed, so that we can discuss the issue further. It would help us to look into the issue and provide you with an alternate solution if possible.

    Thanks,

    Manpreet Kaur

  • Posted 8 September 2017, 9:47 am EST

    Hello,

    1. I agree an event is raise just not BOTH events as I would expect. I have modified the alert message to demonstrate what I am talking about. If you add just the RangedChanged event then this event fires fine. But if you add a RangeChanged and the key map, ONLY the key map event fires, not both as I would expect. I have tried it in FF 31, Chrome 36 and IE 11.

    2. My goal is to validate input the user is filling into the spreadsheet via an ajax response. I do not want to have to block the user from exiting the cell and cant use the built in cell validation of spreadjs as it is async. The user may put data into the cell and continue filling data out. I want to be able to validate that data async and notify the user of the problem then change the value back to the previous value or remove it.

      The main problem is there is no way to directly bind a few cells to events, you have to bind a change to all cells. I know you can bind data to a view model (using knockout which I am using), but this will not work if only some of the cells need to be bound to actual data. The spreadsheet may have instructions throughout it and we only care to validate specific cells, and each cell may have a different type of validation required.

    Thanks.

  • Posted 8 September 2017, 9:47 am EST

    Hello,

    1. Thank you for the clarification. However, the behaviour which you are currently observing s the intended behaviour of SpreadJS. The RangedChanged event is raised if no key map has been added for the Delete key. However, if the key map is added then, it would raise only the Key map event.

    2. Thank you for the elaboration. I have escalated the issue to the concerned team for further discussion. I would let you know as soon as I get any information in this regard.

    Thanks,

    Manpreet Kaur

  • Posted 12 April 2018, 6:58 am EST

    Hello

    theres No event for delete In spread.js. actully i want to perform validation based on delete event

    but I’m stuck here

    when you all have any solution then please reply

Need extra support?

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

Learn More

Forum Channels