This is a migrated thread and some comments may be shown as answers.

Onchange Event

2 Answers 295 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
Marc
Top achievements
Rank 1
Marc asked on 06 Apr 2017, 09:05 PM

When the user clicks in a certain column, we make it into a dropdown (using range.validation(String here). We have to do this because there are over 10,000 rows and adding different validations to each takes too long.

However - we also have an onchange method, which fires when this dropdown (validation) is added as technically the cell value has changed (from the original value, to the new value which is the same as the original, but part of a validation). Is there any way to stop this event firing? Thanks!

2 Answers, 1 is accepted

Sort by
0
Accepted
Michael
Top achievements
Rank 1
answered on 07 Apr 2017, 02:07 PM

I solved this issued in my projects by doing the following:

var isChanging;
 
$(document).ready(function(){  
    isChanging = true;
    //do validation setting here
    isChanging = false;
});
 
function onChange(row,col,cell){
    if(isChanging)
        return;
     
    //other change logic here
}
0
Marc
Top achievements
Rank 1
answered on 10 Apr 2017, 08:49 AM

Hi Michal,

This is a great solution. I'm quite annoyed as I had already implemented this type of thing for when I initially populate the spreadsheet, so I do the same thing with a variable called intialDataLoad. Thanks again for the help!

Marc

Tags
Spreadsheet
Asked by
Marc
Top achievements
Rank 1
Answers by
Michael
Top achievements
Rank 1
Marc
Top achievements
Rank 1
Share this question
or