0

im using this code to filter based in which checkbox is selected,

positiveFilter= RowFilters.regexFilter(0, "^pos", columnStatus);
        neutralFilter = RowFilters.regexFilter(0, "^neu", columnStatus);
        negativeFilter  = RowFilters.regexFilter(0, "^neg", columnStatus);

according to the selected checkbox, it add the filter to the List

filters = new ArrayList<RowFilter<TableModel, Object>>();

so i set the filters to one Filter

RowFilter<TableModel, Object>  compoundRowFilter  = rowFilter.orFilter(filters);

and then: jxTable.setRowFilter(compoundRowFilter);  //im using JXTable

the problem now is that i need to filter the results based on the date TOO,

HERE I GET the date between the 2 selected dates, and than add to the filter, so it will check for the row Text if it starts/match

filtersData = new ArrayList<RowFilter<TableModel, Object>>();
            dates = new ArrayList<LocalDate>();
            for (Date data : obtenerFechasDiariasIntervalo(jxdatainicial.getDate(), jxdatafinal.getDate())) {
                filtersData.add(RowFilters.regexFilter(0, "^" + longFormat.format(data) + "", 5));
            }

but its impossible to use both filters together i think

like:

compoundRowFilter = RowFilter.orFilter(filtersData).orFilter(filters);

if i use this above, it return me all the results based on the checkbox

if i use the andFilter(filters); it stop working when i select more than one checkbox...

ps: im trying to avoid a new query to the database to use a specific daterange method

since the data is not all the time changed i dont need to check everytime..

BUT i think this is only the real way =\

user2582318
  • 1,607
  • 5
  • 29
  • 47
  • 1
    Please edit your question to include a [complete example](http://stackoverflow.com/help/mcve) that exhibits the problem you describe, for [example](http://stackoverflow.com/q/17854854/230513). – trashgod Oct 03 '14 at 21:06
  • [You can write your own filter](http://stackoverflow.com/a/25950000/2587435) – Paul Samsotha Oct 04 '14 at 04:48
  • There's also a [`dateFilter`](http://docs.oracle.com/javase/7/docs/api/javax/swing/RowFilter.html#dateFilter%28javax.swing.RowFilter.ComparisonType,%20java.util.Date,%20int...%29) – Paul Samsotha Oct 04 '14 at 04:52

0 Answers0