0

我使用此代码根据选中的复选框进行过滤,

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

根据选中的复选框,它将过滤器添加到列表中

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

所以我将过滤器设置为一个过滤器

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

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

现在的问题是我需要根据日期过滤结果,

在这里我获取两个选定日期之间的日期,然后添加到过滤器中,因此它将检查文本行是否开始/匹配

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));
            }

但我认为不可能同时使用两个过滤器

喜欢:

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

如果我在上面使用它,它会根据复选框返回所有结果

如果我使用 andFilter(filters); 当我选择多个复选框时它停止工作...

ps:我试图避免对数据库进行新查询以使用特定的日期范围方法

由于数据并非一直都在更改,因此我不需要每次都检查..

但我认为这只是真正的方式=\

4

0 回答 0