I have a table which has rows with dependent rendering of values, something like:
[STATUS, VALUE]
Where STATUS could be “On” or “Off”. If “On” then VALUE should show (it’s a number), if “Off” then VALUE should be hidden, but not actually cleared. Simply changing STATUS on a row should update the display of VALUE for that row.
So I made a renderer for the VALUE column like this:
function valueRenderer(instance, td, row, col, prop, value, cellProperties) {
Handsontable.renderers.NumericRenderer.apply(instance, arguments);
if (instance.getDataAtRowProp(row, 0) == "Off") {
td.innerHTML = "";
}
return td;
}
This works, and to my surprise changing the STATUS seems to re-render the VALUE column for that row.
Example: http://jsfiddle.net/d2emkg0a/2/
This surprised me (in a good way, but I want to understand why), because I expected to have to write a trigger (say from afterChange) to update the VALUE column after a change to the STATUS column. Now I’m wondering why this works? Has my code somehow triggerd the table to re-render() after every change? Or does Handsontable track dependencies automatically when you call getDataAtRow during the renderer, so that it knows a change to col 0 requires redraw of column 1?