ce icon indicating copy to clipboard operation
ce copied to clipboard

onchange event setValue

Open TsePakKwan opened this issue 7 years ago • 4 comments

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.

TsePakKwan avatar Jun 27 '19 03:06 TsePakKwan

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);
}

PRISMAY avatar Jun 28 '19 13:06 PRISMAY

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;

}

pphod avatar Jun 29 '19 09:06 pphod

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; } }

kimmanlui avatar Jul 17 '19 04:07 kimmanlui

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'.

saguila avatar Mar 25 '21 00:03 saguila