Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTable - Enable filtering but disable sorting

 
Payam Fard
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have a jtable for which I would like to have filtering capabilities but disable sorting. Right now, I can filter the values shown in the table but user can also click on the table header to sort the values. How I can disable sorting while keeping the filtering?

Thanks.
 
Darryl Burke
Bartender
Posts: 5132
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem.

Also, read the API for DefaultRowSorter -- there's a method that determines whether each column is sortable.
 
Payam Fard
Ranch Hand
Posts: 75
 
Darryl Burke
Bartender
Posts: 5132
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Where's that SSCCE?
2. How many methods are declared in the DefaultRowSorter class?
3. Of those, how many are mutators?
4. What does each of those mutators set?
 
Kelly Nichols
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you figure out how to solve this problem? I too would like to filter out some rows, but not have the table sorted when you click the header. I was thinking about resorting to a glass pane over the headers.
 
Darryl Burke
Bartender
Posts: 5132
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer to this one is still the same:
Darryl Burke wrote:... read the API for DefaultRowSorter -- there's a method that determines whether each column is sortable.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic