问题描述:

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();"

相关阅读:
Top