显示一组数据表中正确的数据表
参考这篇关于primefaces的帖子论坛。
有人知道如何在同一页面上使用多个数据表但只显示正确的数据表吗?
我的问题是我有一个视图作用域 bean,其属性包含来自数据库中不同表的数据。我有多个数据表用于每个数据库表的数据。现在我想根据从
(以红色圈出)中选择的基础值显示数据表。
这个屏幕截图会进一步解释一些。
Referring to this post on primefaces forum.
Has someone got any idea how can we use multiple datatable on the same page but only display the correct one?
My problem is that i have a view-Scoped bean whose properties contain data from different tables from a database. I have multiple datatables for data of each database table. Now i want to display the datatable on the basis value selected from <p:selectOneMenu>
(encircled in red color).
this screenshot would explain a bit further.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
基本方法是让表格的
rendered
属性取决于菜单中所选的项目。这很容易实现,但是您最终会在视图中看到大量代码(当然可以将其拆分为
文件)。更高级且可重用的方法是让单个表的值取决于菜单中选定的项目并使用
动态生成列。类似这样:
每当您想要添加更专业的列时,这只允许不太细粒度的控制。您可能想使用标签文件。
The basic approach would be to let the
rendered
attribute of the tables depend on the selected item of the menu.This is easy to implement, but you end up with a lot of code in the view (which can of course be split over
<ui:include>
files). The more advanced and reuseable approach would be to let thevalue
of the single table depend on the selected item of the menu and use<p:columns>
to generate columns dynamically.with something like:
This only allows less fine-grained control whenever you want to add more specialized columns. You'd probably want to work with tag files instead.
靠着神的恩典。经过一番挣扎!我终于实现了这个!
为此,我非常感谢 BalusC 的专家提示
所以我想与大家分享我的解决方案。
所以这是我在 xhtml 文件中所做的:
和支持 bean 中:
此代码片段将完全按照我在该屏幕截图中想要的方式工作! :-)
另外,如果有人发现某些内容无法解释或丢失,请发表评论。
再次向 BalusC 致敬。因为如果没有他的提示,我将无法实现这个目标。 :-)
我还要感谢 Optimus Prime 和 PrimeFaces 团队创造了如此精彩的面孔。 :-)
我还要感谢 Stackoverflow 团队,为我们提供了这样一个精彩的讨论平台! :-)
谢谢大家! :-)
By the grace of God. After lots of struggle! i finally achieved this!
For this i pay bundles of thanks to BalusC for his expert tips
So i would like to share my solution with all.
So here is what i did in my xhtml file:
and in the backing bean:
This code snippet would work exactly as i wanted in this screenshot! :-)
Also if someone find something left unexplained or missing, please write a comment.
And again hats off to BalusC. Because without his hints, i won't be able to achieve this objective. :-)
I would also like to say thanks to Optimus Prime and the PrimeFaces team to create such wonderful Faces. :-)
i would also pay my thanks to the Stackoverflow team, for providing us such a wonderful platform for such discussions! :-)
thank you all! :-)