Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to combine groups of filters for a TableModel using setRowFilter

 
joe encalada
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys.

I have a tablemodel of five columns then I need to apply filters in this order. First I need to filter TAXI in column 0 then to filter OBS in column 2 and finally STATUS in column 3.

I have tree groups of buttons on three JPanels and tree groups of variables for those three JPanels.

Inside every JPanel there is an orFilter:

for TaxiPanel :
column0
filtersTaxi=(TAXI01 or TAXI02 or TAXI03 or TAXI04 or TAXI05 or TAXI06)

for ObsPanel :
column2
filtersObs=(Confort or Mechanical)

for StatusPanel :
column3
filtersStatus=(Process or Finished)
      
So what I'm trying to get is a something like this:

            totalFiltered=(totalFilteredTaxi && totalFilteredObs && totalFilteredStatus)

  

But I can't find a way.

I've been progressing with your help I hope you can help me again.
 
joe encalada
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is my code working but not combined.

 
Rob Camick
Ranch Hand
Posts: 2673
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all post a proper SSCCE when asking a code. The reason your last question had 18 replies is because you didn't simplify the code or question.

Your question is about using a filter so there is absolutely no need to post 500 lines of code. All you need is a JFrame with a JTable and some data in the table. A SSCCE can be created in about 20-30 lines of code.

Read the section from the Swing tutorial on Sorting and Filtering for the basics and simple code to learn from.

The following code is modified from the TableFilterDemo and shows how to use the "RowFilter.andFilter(...)".



Change the demo code to get it working. Then once you understand the basics you can fix your real code.

 
joe encalada
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have found a solution creating these to variables to make the AND filtering:

so that from the code I posted:
First group of filters:

Second group of filters:

Third group of filters:

I hope it can help to others.

Rob. Thanks for your suggestions.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic