How do I get the full data from a Handsontable instance that has been modified and filtered?

Tags: #<Tag:0x00007f8b1d9fb3e8>

I believe my issue is easier to illustrate in an example:

Assume I have a Handsontable instance. When I display it in a browser, there are 150 rows with 10 columns. Now assume I apply a couple of change, move some columns and rows around, modify a lot of cells and what not.

After this, I filter one of the columns, and now only 48 rows with 10 columns are being displayed. This is where I’m running into issues.

When I call:

var data = hot.getData();

The data ends up only containing the 48 rows, not the unfiltered 150 rows of data. There’s nothing wrong with this method as it is working as it’s intended, but I was having issues finding a method that would return the full 150 rows that also have the modification applied above (the column and row moving, modifying cells, etc.). Any help would be appreciated.

Hey Tim,

have you tried the getSourceData as well?

Wow. Can’t believe I didn’t see that. Thanks.

I guess it is by design, but getSourceData() does not participate in column/row reordering. If I were trying to retrieve all of the data in the table, with reordering rows/columns and cell changes, but without the filters, would something like this be the best avenue:

hot2 = clone(hot);
hot2.getPlugin('Filters').clearConditions();
hot2.getPlugin('Filters').filter();
var data = hot2.getData();

It’s just unapplying the filters of a separate, non-displayed variable and then pulling the data that is still reordered and what not.

EDIT: Turns out getting a clone of the original hot object is turning out to be pretty tough…

1 Like