I want integrate handsontable to my site, but a got a problem, when im trying to save data created by RuleJS (formula support), script give me a formula back like (=$A1*$B1). Im trying to get result of simple math multiply price and currency. How to save table values, not from sourse?
The workig code is on jsfiddle: http://jsfiddle.net/zetwin/qhjuuk5j/4/
document.addEventListener("DOMContentLoaded", function() {
var people = [
{base_price :'99', price:'13', unit:'=A1*B1'},
{base_price :'89.99', price:'13.43', unit:'=A2*B2'}
],
example1 = document.getElementById('example1'),
settings1;
settings1 = {
data: people,
formulas: true,
rowHeaders: true,
colHeaders: true,
colHeaders: [
'Price', 'Currency', 'USD'],
columns: [
{data: 'base_price'},
{data: 'price'},
{data: 'unit'}
]
};
var hot = new Handsontable(example1, settings1);
$('.push').click(function () {
data = hot.getData();
console.log(data);
//$('.result').text(data);
});
});
Thank you!
An object is a property Handsontable plugin.matrix.data - a list of cells, which are calculated according to the formulas in the table. Each cell has a property value - this is the displayed result. To get all of the data will have to use the function: Handsontable.plugin.helper.cellValue or Handsontable.plugin.helper.cellRangeValue.
For example for your jsfiddle:
to get from the top-right of the cell:
I think that is a better method than cellRangeValue not. But on this basis we can write something more comfortable. See. Handsontable.plugin.helper.cellRangeValue