Delete row from jTable ordered or filtered, associated to a database?

0

I have a JTable that feeds from a database, if I keep the table static and use the code that I paste at the end of this comment, which is to delete the selected row, it performs correctly both of the table as of the data base. But when deleting a selected data, after filtering or sorting the table; does not delete the selected data.

For example, if it is filtered and only one data remains, when I delete it, it deletes the data from the first row of the original table; Or, if I order the data and in spite of wanting to delete the data of the third row of the ordered table, it deletes the data of the third row of the original table.

So my question is, how to delete a data from the table after ordering it and filtering it? First of all, Thanks.

int fila = tbNivel.getSelectedRow();
int columna = 0;
TableModel modelo = tbNivel.getModel();
String id = modelo.getValueAt(fila, columna).toString();
RegistroNivel registro = new RegistroNivel();
if(registro.eliminar(id)==1){
    JOptionPane.showMessageDialog(this, "Eliminado: "+id);
}
    
asked by Mario Catete 16.07.2018 в 21:27
source

0 answers