Determine Filtered rows in table model

1,378 views
Skip to first unread message

Rajiv Jha

unread,
Nov 26, 2010, 1:20:04 AM11/26/10
to tablefilter-swing
Hi,

I am using table filter and must admit its a great tool.
However I have an requirement where i need to export filtered rows
from Jtable to Excel.
I have a List of table data (model), which all gets exported to excel.
I am not able to determine which data from list are currently part of
table (due to filtering).

Is there any way to relate filtered row from table to model.

Please help me to solve this problem.

Thanks

Rajiv Jha

coderazzi

unread,
Nov 26, 2010, 8:06:47 AM11/26/10
to tablefil...@googlegroups.com
Hi, Rajiv,

You can obtain the RowSorter from the table by invoking JTable.getRowSorter().

Then, to know if a row in the model is filtered out or not, you could call

RowSorter.convertRowIndexToView()

which returns -1 if the row is filtered out of the view.

If JTable.getRowSorter() returns null, you can assume that there is no
filtering, but using TableFilter, there is always an associated
RowSorter

This will work if you are using Java 6, is that the case?

Hope this helps!

Lu.

Rajiv Jha

unread,
Nov 27, 2010, 6:03:05 AM11/27/10
to tablefilter-swing
Thanks Lu.
It was really useful.

- Rajiv Jha



On Nov 26, 6:06 pm, coderazzi <l...@coderazzi.net> wrote:
> Hi, Rajiv,
>
> You can obtain the RowSorter from the table by invoking JTable.getRowSorter().
>
> Then, to know if a row in the model is filtered out or not, you could call
>
> RowSorter.convertRowIndexToView()
>
> which returns -1 if the row is filtered out of the view.
>
> If JTable.getRowSorter() returns null, you can assume that there is no
> filtering, but using TableFilter, there is always an associated
> RowSorter
>
> This will work if you are using Java 6, is that the case?
>
> Hope this helps!
>
>   Lu.
>
Reply all
Reply to author
Forward
0 new messages