boombard
boombard

Reputation: 21

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);
};

Upvotes: 1

Views: 1249

Answers (1)

adriaan_se
adriaan_se

Reputation: 36

Just try putting the sumRendered declaration above your Handsontable object

Upvotes: 1

Related Questions