handsontable / docs-archive

API Documentation for Handsontable
6 stars 505 forks source link

Handsontable - Formula field retrieval issue #30

Closed karthikcsridhar closed 8 years ago

karthikcsridhar commented 8 years ago

I have formula fields that reference other formula fields in my handsontable. While retrieving some of the formula fields I have issues, where I am getting the formula instead of the calculated value.

I have tried 2 ways of retrieving the formula fields as below,

Method One:

var cellId2 = myht.plugin.utils.translateCellCoords({row: rowNum,col: colNum});
var res1 = myht.plugin.helper.cellValue(cellId2);

When above fails, it returns the formula itself instead of the value.

Method Two:

var formula = myht.getDataAtCell(rowNum, colNum);
formula = formula.substr(1).toUpperCase();
var newValue = myht.plugin.parse(formula, {row: rowNum, col: colNum, id: cellId2 });

When above fails, newValue object has errors as shown below, {error: "#VALUE!", result: null}

Following is a jsfiddle that shows the problem. https://jsfiddle.net/76z48m98/3/

View the problematic retrievals in the console after clicking the button in the fiddle. If it works fine without issues, probably try 2-4 times clicking button or refresh jsfiddle & try, you can see the issue happen, as sometimes(rarely) everything works fine.

As I understand it, when the libraries calculate the formula, sometimes if the referenced cells are formula cells again, it sometimes retrieves the formula itself of the referenced cells instead of the actual value, leading to isNaN and it fails.

AMBudnik commented 8 years ago

Hi @karthikcsridhar I've marked this issue as bug already at https://github.com/handsontable/handsontable/issues/3209 Please do not duplicate issues.

karthikcsridhar commented 8 years ago

Apologies, I thought I posted the issue in handsontable/ and when I checked there again it was not there. So thought it was discarded or something and posted again. Didn't realize I posted in docs section by mistake.