在 p:dataTable 上使用过滤器时,Ajax 更新不起作用 [英] Ajax update doesn't work, when using filter on p:dataTable

查看:14
本文介绍了在 p:dataTable 上使用过滤器时,Ajax 更新不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含primefaces过滤功能的数据.可以对表进行一些操作(例如编辑).用户使用ajax完成操作后,dataable会被更新.它直接更新表并且运行良好,如果我不过滤数据表,不幸的是如果我使用它并编辑它.

I have a datable which includes the filter feature of primefaces. Some operations can be done on the table (e.g. edit). The datable will be updated after the user's operation is completed using ajax. It updates the table directly and works well, if I don't filter the datatable, unfortunately not if I use it and edit it.

这就是我的数据表的样子:

That's how my datatable looks like:

    <p:dataTable id="dataTable" var="row"
                value="#{bean.value}"
                filteredValue="#{bean.filteredValue}"
                paginator="true" rows="25" paginatorPosition="bottom"
                rowKey="${row.id}"
                paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
                editable="true">

和触发更新的按钮

<p:commandButton value="Save"
                        actionListener="#{bean.save}"
                        update=":form"/>

推荐答案

更新datatable后,你必须调用它的客户端filter()方法.

After updating datatable you have to invoke it's client side filter() method.

<p:dataTable widgetVar="dataTableWidgetVar" id="dataTable" var="row"
             value="#{bean.value}"
             filteredValue="#{bean.filteredValue}"
             paginator="true" rows="25" paginatorPosition="bottom"
             rowKey="${row.id}"
             editable="true">

<p:commandButton value="Save"
                 actionListener="#{bean.save}"
                 update=":form"
                 oncomplete="PF('dataTableWidgetVar').filter()"/>

对于 5 之前的 PrimeFaces 版本,您应该使用

For PrimeFaces versions older than 5, you should use

<p:commandButton value="Save"
                 actionListener="#{bean.save}"
                 update=":form"
                 oncomplete="dataTableWidgetVar.filter()"/>

这篇关于在 p:dataTable 上使用过滤器时,Ajax 更新不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆