[英]JTable, RowSorter, getSelectedRow data
I'm using RowSorter in JTable and when I sort one of the column and call the method getSelectedRowData() it return wrong data. 我在JTable中使用RowSorter,当我对其中一个列进行排序并调用方法getSelectedRowData()时,它返回错误的数据。
public Object getSelectedRowData()
{
if(getDataArray() != null)
{
if(grid.getRowSorter() != null)
return ((GridModel) grid.getRowSorter().getModel()).getData().get(grid.getSelectedRow());
else
return model.getData().get(grid.getSelectedRow());
}
else
return null;
}
I think that the problem is that the sorter sort the table data but the ArrayList with data isn't reloaded. 我认为问题在于分拣机对表数据进行排序,但不重新加载带有数据的ArrayList。 How I can fix it? 我该怎么办呢?
要获取当前选定的数据,您可以将选定的行号转换为模型行号。
jTable1.convertRowIndexToModel(jTable1.getSelectedRow())
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.