在p:dataTable上使用过滤器时,Ajax更新不起作用 [英] Ajax update doesn't work, when using filter on p:dataTable
问题描述
如果我不过滤数据表,直接更新表,并且工作得很好,不幸的是,如果我使用它并对其进行编辑,那么
$ b 这就是我的datatable看起来像:
< p:dataTable id =dataTablevar =row
value = #{bean.value}
filteredValue =#{bean.filteredValue}
paginator =truerows =25paginatorPosition =bottom
rowKey =$ {row .id}
paginatorTemplate ={CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}
editable =true>
和触发更新的按钮
< p:commandButton value =Save
actionListener =#{bean.save}
update =:form/>
更新数据表不得不调用它的客户端 filter()
方法。 p:dataTable widgetVar =dataTableWidgetVarid =dataTablevar =row
value =#{bean.value}
filteredValue =#{bean.filteredValue}
paginator =truerows =25paginatorPosition =bottom
rowKey =$ {row.id}
editable =true>
< p:commandButton value =Save
actionListener =#{bean.save}
update =:form
oncomplete =PF ( 'dataTableWidgetVar')滤波器()/>。
对于5以前的PrimeFaces版本,您应该使用
< p:commandButton value =Save
actionListener =#{bean.save}
update =:form
oncomplete =dataTableWidgetVar.filter()/>
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">
and the Button which triggers the update
<p:commandButton value="Save"
actionListener="#{bean.save}"
update=":form"/>
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()"/>
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屋!