I want to concatenate values from a handsontable grid. So, I found something on jsfiddle and I'm trying to adapt it in my case.
Here is the link :
http://jsfiddle.net/9onuhpn7/4/
So I have 3 columns A,B,C and I'm trying to concatenate them and display the result in "SUM" column, but it's not working.
As I said, it's a code that I took from another guy and I don't understand this line if (changes[i][1] === 3) {
and if I take it off, it doesn't work anymore. If someone can tell me what's the purpose of that.
Someone can help me please ?
The code you took is a bit weird. I updated it a bit to better suit what you're looking for.
(PS: I'm not a Handsontable user)
Basically, the problem seems to be that you're listening to a change event, and in this change event, you're doing some changes. This may lead you to infinite event loop.
The line
if(changes[i][1] === 3)
is just here to prevent this loop. Basically, if the change occurred on the 'SUM' cell which is at coords [i,1], then, we do not want to trigger the change again (as it just happened).
Take a look at this code: http://jsfiddle.net/9onuhpn7/6/
When calling setDataAtCell(), you can associate a name to the change. This name will be the 2nd parameter of the afterChange listener.
You simply have to use a condition on the source name of the event to trigger it or not.