• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Taking controll over sorting in JTable

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,

I want to use JTable's standard sorting mechanism with TableRowSorter which works fine. But I want to have the control about when sorting is done. Sorting is triggered by JTable if the TableModel what is not what I want. I want to occur sorting only if the user clicks on the table header and by explicitly calling the sort method. Is there any way to achieve this?

Regards,
Christian
 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
did you try calling the jTable.setRowSorter() in the table header's event method when it is clicked?

 
Christian Kindler
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

mark goking wrote:did you try calling the jTable.setRowSorter() in the table header's event method when it is clicked?



The problem with installing/removing the row sorter as needed is, that the table will restore the unsorted state when the RowSorter is removed.
 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well I only checked that JTable notifies rowSorter if table's sortManager is != 'null' through tableChanged method, and this may work.. If you dont want table to sort every time the model changes...

reply
    Bookmark Topic Watch Topic
  • New Topic