Handsontable: Saving only rows with data in it

Created on 14 Jan 2014  路  3Comments  路  Source: handsontable/handsontable

Is there a way to send only rows with data in them? Handsontable automatically creates an empty row under the row you are typing in. When I post that data I do not want that empty set of data. How do I delete that empty row?

Question

Most helpful comment

I did something like this:

var gridData = hot1.getData();
var cleanedGridData = {};

$.each( gridData, function( rowKey, object) {
    if (!hot1.isEmptyRow(rowKey)) cleanedGridData[rowKey] = object;
});

All 3 comments

Handosntable will automaticaly create an empty row at the bottom of a table, only if you set minSpareRows option to a value greater than 0.

If you want to send only rows with data, you should filter you data source before posting it to the server.

maybe you can use .slice(0, datasource.length-1);

I did something like this:

var gridData = hot1.getData();
var cleanedGridData = {};

$.each( gridData, function( rowKey, object) {
    if (!hot1.isEmptyRow(rowKey)) cleanedGridData[rowKey] = object;
});
Was this page helpful?
0 / 5 - 0 ratings