JTable filled with database data is not being updated when columns are reordered.
Posted
by marionmaiden
on Stack Overflow
See other posts from Stack Overflow
or by marionmaiden
Published on 2010-04-12T13:23:09Z
Indexed on
2010/04/28
21:37 UTC
Read the original article
Hit count: 382
I have a JTable filled with data of a table of my database (so I used ResultSetTableModel) and using TableRowSorter to sort the rows, as I click in one column of the JTable. The data is displayed in the jTable without problems;
But when I sort the JTable by some column table (for example, sorting it by the primary key value), and edit some cell from the sorted jTable, the value changed is the old cell that were in that position before the ordenation of the column.
For example: Suppose I have a table with 2 columns - name and age. My table has the following data:
c 1
b 2
a 3
when I order i by name in the JTable, it becomes like this
a 3
b 2
c 1
if I edit the value "1", after the edition, the table becomes like this
a 1
b 2
c 1
It seems that the positions are not being updated in the JTable, and the values are edited considering their original positions.
© Stack Overflow or respective owner