Displaying results as "pages" of a JTable and sorting across all results ...

M

Monique Y. Mudama

Hi all ...

I've recently returned to the world of Java after an extended
sabbatical, but I'll admit that my grasp of TableModels and such was
never all that great.

So now I have a JTable question ... and it seems like such a common
need that there must be an obvious, known solution ...

I need to display a lot of results, one "page" at a time. I imagine a
JTable which is repopulated when the user clicks on a "Next" button.
On the face of it, that part seems pretty easy. I already have a
JTable that's repopulated based on new search terms.

Now, the result set in this case may be huge -- I simply can't request
the entire set of data at once. I can, however, query for results x
through y of the full set, and I can request the total number of hits.
Populating the TableModel and calling fireTableDataChanged(), again,
not a problem.

Here's the problem. I need the table to be sortable such that if the
user requests a change in the sort order of a column, the sort will take
effect across the entire set of data. If there were 100 hits and the
user is looking at the first 15, then clicks on the column heading, the
JTable would display the last 15 in reverse order. But again, I can't
have the full 100 (or 1,000 or 10,000) available locally; I would need
to query. I can query for the "first 15, descending order", that's not
a problem. But how do I go about modifying TableSorter.java to do this?
When the user clicks on the header to sort by the column, instead of
actually sorting, I want to send a query and repopulate the table based
on the query.

Any pointers, hints, etc. gratefully accepted. I'm sure this is a
dumb question, but I can't seem to figure it out.
 
M

Monique Y. Mudama

On 2005-06-27, Monique Y. Mudama penned:

[snip]

Looks like I was making things too complicated. A listener on the
JTableHeader ... that's what I needed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top