jsf - p:datatable 组件不排序,只有当我过滤它之前
问题描述
我试图在 Datatable 中显示我的 mysql 数据库中的数据,并且一切正常,现在我试图包含一个过滤器和排序功能,但是当我测试它并按下排序箭头时,没有任何反应,只有当我过滤首先是数据表,然后一切正常。
我尝试使用 primeface Attributes filterBy 和 sortBy,并且由于现有功能,我认为它与更新问题有关
<p:dataTable id="test3" scrollable="true" scrollHeight="150" var="Foo" value="#{Foo.bar}">
<p:column headerText="#{msg['default-description-key']}"
sortBy="#{Foo.keyString}"
filterBy="#{Foo.keyString}">
<p:outputLabel value="#{Foo.keyString}"
style="float:center"/>
</p:column>
<p:column headerText="#{msg['default-description-count']}"
sortBy="#{Foo.count}" filterBy="#{Foo.count}">
<p:outputLabel value="#{Foo.count}"
style="float:center"/>
</p:column>
<p:column headerText="#{msg['default-description-register.key']}">
<p:commandLink value="#{msg['default-description-
register.key.link']}" action="#{Foo.bar(Foo.keyString)}"/>
</p:column>
</p:dataTable>
我希望能够对数据表进行排序而无需之前对其进行过滤
解决方案
- 在您的 bean 中创建一个单独的列表(不要忘记 getter 和 setter)并将其链接到 p:dataTable 组件中的属性 filteredValue
- 将表格放在 h:form 中
- 使用 h:outputText 而不是 p:outputLabel
推荐阅读
- html - margin-block-start 和 margin-top 有什么区别?
- python - Selenium - 不需要的表单填充 - Python
- java - 有什么方法可以在 listView 中获取特定视图?
- docker - 在不使用 docker swarm 的情况下处理 docker 容器内的秘密
- powershell - PowerShell 脚本返回“远程服务器返回错误:(401) 未经授权”
- javascript - 通过使用 laravel 比较数据库日期来限制 datepicker 的日期范围
- nginx - 如何将我的整个网站重定向到 archive.org?
- python - 安装 pyttsx3 时:命令出错,退出状态为 1
- r - 配置 docker 容器以使用主机 UID 并在主机系统上生成文件 - 最好在运行时
- cloud - 云计算中的能效任务调度