I am looking for a way to remove filter selections/reset filter to all (to be placed in the internal frame closing script on pages) in a power table. I couldn’t find anything related to resetting filters in documentation or scripting areas. Perhaps there is a way to make columns un filterable then make them filterable again as a way to reset. I couldn’t find a way to accomplish this either, however. Any ideas? Thanks!
Forgive the last line of this script:
table = event.source.parent.getComponent('Power Table')
table.getTable().getTableHeader().clearFilters()
table.data = table.data
This will reset your filter(s). There are more elegant ways of triggering a table repaint than simply reinitializing the data in the table, but the usual suspects didn’t quite work when I mocked this up. For you this might be a system.db.refresh() call or some other assignment.
Alternately without that fun last line, create a custom method for the power table like this
def clearFilters(self):
model = self.getTable().getModel().getActualModel()
model.clearFilters()
model.setFiltersApplied(True)
model.refresh()
documentation link: http://www.jidesoft.com/javadoc/com/jidesoft/grid/FilterableTableModel.html
To selective clear filters by column
model = self.getTable().getModel().getActualModel()
def clearFilters(col):
if model.hasFilter(col): [model.removeFilter(col,filter) for filter in model.getFilters(col)]
clearFilters(col)
clearFilters(0)
clearFilters(1)
clearFilters(3)