I am looking for a way to dynamically bind formulas throughout my DOM.
We have a data intensive app, and currently I write many handlers to try and recalculate and update the appropriate cells. However, this is error-prone.
I saw something that might be capable, hashigo. However it hasn’t been updated in about a year and a half.
Does anyone know of something similar that is under active development? I have been searching, but this is all I have managed to find.
Ideally I only need to setup the formula, and it will handle monitoring if fields in the formula have changed, and update the value accordingly.
EDIT: I also jQuerySheet however it is way more than I can use, I just need the formula parsing aspects of it. And it’s calculation engine appears to revolve too much around cells with a column/row identifier.
EDIT2: This jQuery Calculation plugin is getting closer to what I need.
EDIT3: Ultimately, I’d love to be able to write out something as simple as
$('#output').formula(" ( SUM($('.x')) + $('#y') ) / ( funcThatReturnsValue() + 4 )");
Which would result in the value of #output being recalculated whenever a value in .x or #y changed.
However, I may would setting for something as basic as this
$('#output').formula({
formula: "(SUM(x)+y)/(j+k)",
variables: {
x: $('.x'),
y: $('#y'),
j: function() {
return 3;
},
k: 4
}
onblur: $('.x, #y')
});
You can use knockout.js to get the functionality you’re looking for.
Knockout.js implements an mvvm pattern in your javascript. Here is how they define MVVM:
So you’ll create your “model” which includes the data in the spreadsheet, along with any functions you need to recalculate data. Then you’ll have your view, which automatically updates (aka recalculates) the data as the user changes things on the page.
http://knockoutjs.com