vendredi 30 janvier 2015

Custom renderer not applied on Table render handsontable

I have a custom renderer for summing the columns in my handsontable.


The values are only shown when a cell is edited, but not when the table loads with its initial data.


Is there some event to load the initial rendering? Or am I calling the renderer incorrectly?



hot = new Handsontable(container, {
data: data,
colHeaders: col_headers,
rowHeaders: row_headers,
colWidths: 110,
rowHeights: 30,
startRows: row_count,
maxRow: row_count,
maxCols: col_headers.length,
columns: column_types,
cells: function(row, col, prop){
if (row === row_count - 1) {
this.renderer = sumRenderer;
var cellProperties = {};
cellProperties.readOnly = true;
}
return cellProperties;
}
});

var sumRenderer = function (instance, td, row, col, prop, value) {
var total = 0;
for (ii = 0; ii < row; ii++) {
total += instance.getDataAtCell(ii, col);
};
value = total;

Handsontable.renderers.NumericRenderer.apply(this, arguments);
};




Aucun commentaire:

Enregistrer un commentaire