onchange event setValue
hi @paulhodel I need set difference formulas when same row other column changed. Relate issue #360
I have already try 'setValue' / 'setRowData' function on handling events(updatetable / onchange ),but can't solve my issue. it will show Error 'Maximum call stack size exceeded error'.
It is because after setValue will call handling events again causing an infinite loop. Could you fix it?
Thanks a lot.
I had the same issue in version 2 and got around it for now by using updateCell. We needed to force a value to uppercase and this works. Hope it helps.
var onChange = function(e, $worksheetInstance, $cell, newValue, oldValue)
{
var position = $cell.attr('id').split('-');
var updateCellOptions = {
col: position[0],
row: position[1],
cell: $cell[0],
newValue: new String(newValue).toUpperCase(),
oldValue: oldValue
};
$worksheetInstance.jexcel('updateCell', updateCellOptions);
}
There is another way to do. You need to disable events...
var changed = function(instance, cell, value) { $.fn.jexcel.ignoreEvents = false; $.fn.jexcel.ignoreHistory = false; $(instance).jexcel('setValue', 'A1', 'test'); $.fn.jexcel.ignoreEvents = true; $.fn.jexcel.ignoreHistory = true;
}
Here is my solution.
var once=0;
var changed = function(instance, cell, x, y,value) {
if (once==0)
{
once=1;
var rownum=parseInt(y)+1; //do whatever
var cellident=updatedcolumnName+rownum+":"+updatedcolumnName+rownum; //do whatever
table.setValue(cellident,"true");
} else
{
once=0;
}
}
The problem is when you set a Value using JExcel functions invoques again the change, the solution is edit cell native component using cell.childNodes[0].data = 'data'.