Apply filter programatically in JideTable and FilterableTableModel

843 views Asked by At

I am trying to apply a filter to an specific column in a table, when all data is loaded in the table (without applying a filter), I have let's say:

Item, Status <- headers

Item0 , 0 Item1, 0 Item2, 0 Item3, 1 Item4, 1 Item5, 1

So I have an Item column and a Status column. When using a FilterableTableModel, I can install the header in the columns so that the user can configure the filters to apply manually.

Custom Filters

So the user could filter for example all Statuses that are '1' by unchecking all the items except 1.

My question is, could I do the same, but programatically?, so that this filter is applied when table is presented, but allowing the user to remove it.

I've tried to create a InFilter and apply it to the table, it actually filters the data, but it doesn't appear in the list (in order to do so I would have to register the filter and it will appear in the custom filter list, but that is something that I don't want to, since I would have to register/unregister the filter every time that I open this dialog), and the user cannot disable it.

1

There are 1 answers

0
bahtiyartan On

Using classes such as javax.swing.table.TableRowSorter, javax.swing.RowFilter and its subclasses, you can add filter to your JTable programatically. In our project we use this classes with jide table without any problem.

My other suggestion to you is search for com.jidesoft.filter.Filter class. It is possible you can find useful tips.