JTable行过滤器

发布于 2024-08-02 19:40:45 字数 87 浏览 2 评论 0原文

是否有可能如何获取与非过滤表相对应的选择的索引?

使用正则表达式过滤器过滤表后。 JTable getSelectedRow 返回过滤表的索引?

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. JTable getSelectedRow returns the index of the filtered table?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

伪装你 2024-08-09 19:40:45

如果您使用 1.6 版本中内置的 TableRowSorter 功能,您可以在表上使用 conversionRowIndexToModel()。这将为您提供所选行的未过滤索引。

JTable 的 javadoc 对此进行了描述:

坐标转换为
使用基于行时必需的
JTable 的方法与底层
表模型。所有 JTables 基于行
方法是就 RowSorter 而言的,
这不一定与
底层 TableModel 的值。为了
例如,选择始终位于
JTable 的条款,以便在使用时
您需要转换的 RowSorter
使用convertRowIndexToView或
将行索引转换为模型。

If you are using the built in TableRowSorter functionality from 1.6 you can use the convertRowIndexToModel() on the table. This is give you the unfiltered index of the selected row.

The javadoc for JTable gives a description of this:

Coordinate conversions will be
necessary when using the row based
methods of JTable with the underlying
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. For
example, the selection is always in
terms of JTable so that when using
RowSorter you will need to convert
using convertRowIndexToView or
convertRowIndexToModel.

时光匆匆的小流年 2024-08-09 19:40:45

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

store the row id in your datamodel, when you get the selected row from jtable, query that rows ID.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文