column filtering with handsontable

2,253 views
Skip to first unread message

fobinator

unread,
Apr 25, 2014, 4:03:34 PM4/25/14
to handso...@googlegroups.com
Hello,

I'm trying to implement some column filtering with handsontable and I'm running into some problems. So far the filtering works well, the problem is when I'm trying to save. This is what I'm doing -

So based on the search terms, I loop through the rows and columns and push into a searchResults array.

if(data[row][colKey].toLowerCase().indexOf(searchTerm) > -1) {
searchResults.push(data[row]);
break;
}

Then I take these results and make this the new data source of the handsontable

$('#dataTable').handsontable({
colHeaders: columnHeaders,
columns: columnData,
data: searchResults
});

So now when the user sees the filtered results and tries to edit and save - the table saves just the filtered view rather than the entire table (because the filtered results is now the new datatable)

To get around this, my initial thought is to try to merge the original table data and the new changed searchResults. But before I dig into that I was wondering if anyone knows an easier way to do this?

james...@gmail.com

unread,
Apr 25, 2014, 5:22:28 PM4/25/14
to handso...@googlegroups.com, james...@gmail.com
Never mind, I figured it out.

Mario Tacke

unread,
Apr 25, 2014, 6:22:06 PM4/25/14
to handso...@googlegroups.com, james...@gmail.com
Do you mind sharing your solution with us? :)

fobinator

unread,
Apr 26, 2014, 1:20:50 AM4/26/14
to handso...@googlegroups.com
Well, I'm still testing it, but it looks like if I set the table back to the default array right before I save, the changes get merged. I thought swapping out the data arrays, I would have to manually merge

$('#dataTable').handsontable({
colHeaders: columnHeaders,
columns: columnData,

data: original
});

kishor...@gmail.com

unread,
Mar 23, 2015, 3:42:17 AM3/23/15
to handso...@googlegroups.com, james...@gmail.com
I am looking for an excel like filtering implementation. Any thoughts. fobinator, Can you share your approach?
Reply all
Reply to author
Forward
0 new messages