TableRowSorter 和 RowFilter - 搜索可见和渲染的列

发布于 2024-10-08 21:59:50 字数 243 浏览 0 评论 0原文

我正在使用 TableRowSorter 和 RowFilter 来过滤 JTable 中的数据。我在使用它时遇到了两个问题。

1)我的表有可见列和隐藏列。我想避免搜索隐藏的列。有办法做到这一点吗?

2)我使用自定义单元格渲染器来渲染单元格中的值。我想搜索渲染值而不是实际值。例如,当状态列的实际值为“true”时,呈现的值为“enabled”。当启用搜索文本时,我应该能够看到数据。

你能帮忙吗?

多谢

I am using TableRowSorter and RowFilter for filtering data in a JTable. I have come across 2 issues while using it.

1) My table has visible and hidden columns. I would like to avoid searching hidden columns. Is there a way to do that?

2) I am using custom cell renderers to render the values in the cell. I would like to search the rendered value instead of the actual value. For example when actual value is "true" for status column, the rendered value is "enabled". I should be able to see data when search text is enabled.

Could you please help?

Thanks a lot

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

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

发布评论

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

评论(1

千笙结 2024-10-15 21:59:50

1) 阅读 JTable API 并点击有关“如何使用表”的 Swing 教程的链接。过滤器示例显示了如何对特定列进行过滤

2) 我想您必须创建一个自定义过滤器。在过滤器内部,您需要使用 TableModel 中的值调用prepareRenderer(...) 方法。我从来没有这样做过,所以我无法举例。

1) Read the JTable API and follow the link to the Swing tutorial on "How to Use Tables". The filter example shows how to filter on a specific column

2) I guess you would have to create a custom filter. Inside the filter you would need to invoke the prepareRenderer(...) method using the value in the TableModel. I've never done this so I'm can't give an example.

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