简体   繁体   English

JTable行过滤器

[英]JTable RowFilter

Is is possible to some how get the index of the selection corresponding to the non filtered table? 有可能如何获得与未过滤表相对应的选择索引?

After the table is filter using a regexFilter. 在使用regexFilter过滤表之后。 JTable getSelectedRow returns the index of the filtered table? JTable getSelectedRow返回过滤表的索引?

If you are using the built in TableRowSorter functionality from 1.6 you can use the convertRowIndexToModel() on the table. 如果您使用的是1.6中的内置TableRowSorter功能,则可以在表上使用convertRowIndexToModel()。 This is give you the unfiltered index of the selected row. 这将为您提供所选行的未过滤索引。

The javadoc for JTable gives a description of this: JTable的Javadoc对此进行了描述:

Coordinate conversions will be necessary when using the row based methods of JTable with the underlying TableModel. 当将JTable的基于行的方法与基础TableModel一起使用时,必须进行坐标转换。 All of JTables row based methods are in terms of the RowSorter, which is not necessarily the same as that of the underlying TableModel. 所有基于JTables行的方法都是基于RowSorter的,不一定与基础TableModel的相同。 For example, the selection is always in terms of JTable so that when using RowSorter you will need to convert using convertRowIndexToView or convertRowIndexToModel. 例如,选择始终是根据JTable进行的,因此,在使用RowSorter时,您将需要使用convertRowIndexToView或convertRowIndexToModel进行转换。

将行ID存储在您的数据模型中,当您从jtable获取选定的行时,查询该行ID。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM