2
votes

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.

1
tested it with a global filter and it works. i dont have a coumn-specific filterApostolos
I'm guessing there's something wrong with the logic for handling column filters. I upgraded to PF 6.0 and verified the issue was still reproducible. Changing my table to lazy loading and using a custom DataModel, as per the showcase example, did work though. Not ideal, since the data set I'm working on is already cached and hence I've no need for the lazy loading, but it works and there's not a noticeable performance difference.bendicott
@bendicott then maybe one needs to be marked as duplicate?Roland

1 Answers

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