$('selector').calx('update') is converting cell values to strings internally (2.2.7)
devops-at-alinea opened this issue · 1 comments
I am dynamically adding rows to a spreadsheet and calling $('selector').calx('update')
to rebuild the spreadsheet.
I have another sheet that is using SUM to sum the columns in my dynamic sheet (I update the formula to account for the new rows as in the Dynamic Forms example) : SUM(M0:M10)
The dynamic sheet is populated with 10 rows when the page is loaded, after this new rows are added via a button click event with a default value of 1000.
I have put a trace statement in the SUM function to examine the arguments it receives.
When the page is loaded the arguments passed to the SUM function are
{M0:2919,M1:2658,M2:842,M3:443,M4:4299,M5:4344,M6:6085,M7:300,M8:301,M9:302}
After I add a new row and call $('selector').calx('update')
the arguments passed to the SUM function are
{M0:"2919",M1:"2658",M2:"842",M3:"443",M4:"4299",M5:"4344",M6:"6085",M7:"300",M8:"301",M9:"302"}
Which is strange because the new row M10 is not included and all the values are now strings.
If I call $('#dynamic_sheet').calx('setValue', 'M10', 1000)
on M10 then the arguments passed look like:
{M0:"2919",M1:"2658",M2:"842",M3:"443",M4:"4299",M5:"4344",M6:"6085",M7:"300",M8:"301",M9:"302",M10:"1000"}
M10 is now in the argument list however all the values are still strings.
If I use $('selector').calx('refresh')
instead of $('selector').calx('update')
then the values are not converted to strings however column M10 is still missing from the arguments:
{M0:2919,M1:2658,M2:842,M3:443,M4:4299,M5:4344,M6:6085,M7:300,M8:301,M9:302}
In order to get everything to work correctly I have to:
//add new row M10 (code excluded)
//refresh dynamic sheet
$('#dynamic_sheet').calx('refresh');
//update SUM function
$('#another_sheet').calx('getCell', 'A1').setFormula("SUM(M0:M10)");
//refresh and calc referencing sheet
$('#another_sheet').calx('refresh');
$('#another_sheet').calx('calculate');
This behaviour should be fixed in 2.2.8, the issue reside in cell.prototype.resyncValue which take raw cell value from the element