Categories | Question details Back To List | ||
Save/Reapply filters after load? Is there a good way to reapply filters after loading? I have data in a grid and after a delete/insert it seems the dropdown filters reset but the text box filters do not reset. I'd like to ideally save all of the filters, reload the grid, then reapply the filters that are still valid (Of course a dropdown filter might no longer be valid if you delete the last record containing the value you were filtering by) Any ideas? Thanks Answer posted by Support on Aug 20, 2009 06:56 There are two ways a) you can use onFilterStart event var f_ind=[]; var f_data=[]; mygrid.attachEvent("onFilterStart",function(ind,data){ f_ind=ind; f_data = data; return true; }); now , after reloading you can call grid.filterBy(f_ind,f_data); to reapply last used filters. b) you can use grid.getFilterElement(index) to access filtering element (selectbox or input) and get|set its value when necessary Answer posted by Anthony Nahas on Aug 20, 2009 08:22 I don't know how well that approach works. I save the filters in the filterStart, then after the load, the filters are removed from view (I still dont understand why this is built-in, load shouldn't even touch filters unless the new grid contents invalidated them for some reason). Afterwards, I reload the filters from f_ind and f_data, then call filterBy(f_ind, f_data), which actually works and shows the correct data... But then if I take a filter with a value and set it to nothing, the grid shows nothing at all Answer posted by Supoport on Aug 21, 2009 05:25 >> the filters are removed from view If you are reloading only data ( not the structure of grid ) the values of filters must be preserved ( there was a problem with select box , but it resolved in latest build - updated js file sent by email ) >>But then if I take a filter with a value and set it to nothing What do you mean by "nothing"? Grid expects that not used filters provides an empty string value. Answer posted on Aug 24, 2009 06:11 Could you resend the file, and name it .ngzip I didn't receive the email.
I did use onFilterStart to save the filters, then after the load event is finished I reload those filters, and call filterBy
Answer posted by Anthony Nahas on Aug 26, 2009 07:38 Don't know if this makes any sense.. but the select filter still resets in certain situations. It works fine on updates, but when adding or deleting rows they are reset for some reason (it doesn't happen on all inserts or deletes either.. sometimes it works sometimes it doesn't) Answer posted by Anthony Nahas on Aug 26, 2009 07:44 Also to add more info on how this happens. I load a grid with a lot of different data (select filters will have many possible values). Then I might do another load, but it will be with more refined data (select filters will have fewer possible values). Then I apply some filters, and add a row. After that, the select filters are reset.. Maybe the fact that there are new filter choices in the grid is messing things up. |