当前位置: 动力学知识库 > 问答 > 编程问答 >

jsf 2 - Primefaces datatable pagination resets filter

问题描述:

I'm using a p:datatable with filters and pagination. Both work fine individually, but if I filter first then move to the second page of results, the filter is removed and I'm seeing the second page of the original data set. Here's what my table looks like :

<p:dataTable value="#{bean.products}" var="product"

paginator="true" paginatorPosition="bottom" rows="5"

filteredValue="#{bean.filteredProducts}"

rowKey="#{product.prdctId}">

<p:ajax event="sort" skipChildren="false" />

<p:column headerText="Description" filterBy="#{product.description}" filterMatchMode="contains"

sortBy="#{product.prdctId}">

<h:outputText value="#{product.description}" />

</p:column>

(other columns)

</p:dataTable>

Any ideas?

Using Primefaces 5.2, JSF 2.0.3

Edit : After searching a bit more, I found another post dealing with the same issue, but it was never answered.

网友答案:
<p:dataTable value="#{bean.products}" var="product"
    paginator="true" paginatorPosition="bottom" rows="5"
    filteredValue="#{bean.filteredProducts}"
    rowKey="#{product.prdctId}">
<p:ajax event="sort" skipChildren="false" />
<p:column headerText="Description" filterBy="#{product.description}" filterMatchMode="contains"
        sortBy="#{product.prdctId}">
    <h:outputText value="#{product.description}" />
</p:column>
(other columns)

Add in your datatable: widgetVar="productTable"

in your button add this: oncomplete="PF('productTable').clearFilters();"

分享给朋友:
您可能感兴趣的文章:
随机阅读: