craftleft.gif (3002 bytes)QuickTable
Home | API | Tutorial | Download | Support | Contact topblack.gif (108 bytes)


QuickTable User Cp  |  Register  |  Members  |  Search  |  Help
    |- QuickTable Discussion Forums > Column Post New Topic   Post A Reply
Tablemodel not zero based? printer friendly version
next newest post | next oldest post
Author Messages
Armin
Unregistered
Edit or delete this message Reply w/Quote
Posted Tuesday, September 14, 2010 @ 13:15:40  

Hi,
after setSelectSQL of a dbtable I want to put a Sorter on it:

TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(dbtable.getTable().getModel());
dbtable.getTable().setRowSorter(sorter);
sorter.setComparator(0, new MyStringSorter());
sorter.setComparator(1, new MyIntegerSorter());
...

The problem here: the Tablemodel although ZERO-based has no entries in Column zero (only NULLs).

A solution would be:

sorter.setComparator(1, new MyStringSorter());
sorter.setComparator(2, new MyIntegerSorter());
...

But then the last column

sorter.setComparator(dbtable.getColumnCount(), new MyDoubleSorter());

throws the Exception:
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: column beyond range of TableModel
at javax.swing.DefaultRowSorter.checkColumn(Unknown Source)
...

How can I solve this?
Any idea?

Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Tuesday, September 21, 2010 @ 21:36:47  

Can you use the Quicktable comparator instead of TableSorter?

dbTable.setComparator(Comparator comp);

This page gives details about how to define Comparator.
http://quicktable.org/doc/quick/dbtable/Comparator.html

Post New Topic   Post A Reply Jump to:
Contact Us | QuickTable - A Java DBGrid | Privacy Policy All times are GMT -5 Hours.
Welcome to QuickTable Forums, Guest!  
Login
Username :
Password :
In order to fully utilize the abilities of this board, you are required to register as a member. Registration is free, and allows you to do lots of things including turning on or off certain features of this board. Register now!
Powered by CuteCast v2.0 BETA 2
Copyright © 2001-2003 ArtsCore Studios