Keep filter conditions after handsonatable load

Tags: #<Tag:0x00007efc64946f08> #<Tag:0x00007efc64946dc8>

Hi,
I have a handsontable with filter functionality, if user apply some filters in
afterFilter(conditionsStack) {
HotelFilter = conditionsStack;
},
function I keep filer array in global js varriable HotelFilter.
So my question is how applay this HotelFilter after reload and recreation of handsontable to have same filters selected in same handsontable after reload.

Hi @anishahbazyan131313

Thank you for contacting us. You can use the Filters plugin methods to reapply the conditions. It would look like this:

const filtersPlugin = instance.getPlugin('filters'); 
filtersPlugin.addCondition(conditions); 
filtersPlugin.filter(); 

Where the conditions are the parameters of the previously applied filters. You can read more about this method here: https://handsontable.com/docs/javascript-data-grid/api/filters/#addcondition

Hi @adrian.szymanski thank you for reply. In my code :
afterFilter(conditionsStack) {
OperHotelFilter = conditionsStack;
},
on next handsontable init
afterInit: function () {
const filtersPlugin = this.getPlugin(‘filters’);
if (OperHotelFilter != undefined) {
filtersPlugin.addCondition(OperHotelFilter);
filtersPlugin.filter();
}
},
As you suggested. But seems filtersPlugin.addCondition(OperHotelFilter) not working.