Storing filter values from page to page

Hi,

I have multiple pages that contain dhtmlxgrid tables. I would like to save the filter values (filters are in header) from page to page. So if the user filters by something on one page and leaves the page, after he returns to the page, the filter should still be there (not reset) and filtered by it.

Is there a built in functionality for this? If not, would be the best way to achieve this? Cookies, session variables?

Thank you!

Unfortunately there is no in-built functionality.
You may save the filter values to cookies manually.
Please, try to use the getFilterElement method to get the label of the filter.

val=mygrid.getFilterElement(col_index).value;

I managed to save the filter value fine.

I understand, that I have to call mygrid.filterBy(); method after all the data have loaded.
Is there a way to check for this?

Thank you.

this will put the value to the filter input and force the filtration:

mygrid.getFilterElement(col_index).value=val; mygrid.filterByAll();

That still only works if I manually put in a delay before calling the mygrid.filterByAll(); function.
There might be different connection/computer speeds so I can’t make an accurate prediction on how long it will take to load data in different cases.

It seems like it has to be called after the data has loaded, otherwise it doesn’t work. Is there a way/function that could tell when data have finished loading?

something like:

mygrid.attachEvent("onFinishedLoadingData", function(elements){ mygrid.filterByAll(); });

that’s right. The filters should be applied only when the data is loaded. You may use the callback function of the load() method:

mygrid.load(url,function(){ mygrid.getFilterElement(col_index).value=val; mygrid.filterByAll(); })
or an onXLE event:

mygrid.attachEvent("onXLE", function(){ mygrid.getFilterElement(col_index).value=val; mygrid.filterByAll(); });

Thank you, that seems to be working! :slight_smile: