Primefaces数据表分页重置过滤器

时间:2016-08-23 15:19:43

标签: jsf-2 primefaces filter datatable pagination

我使用带有过滤器和分页的p:datatable。两者都可以单独工作,但如果我先过滤然后移到结果的第二页,则会删除过滤器,并且我会看到原始数据集的第二页。这是我的表格的样子:

<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>

有什么想法吗?

使用Primefaces 5.2,JSF 2.0.3

编辑:在搜索了一下之后,我发现another post处理了同样的问题,但从未接听过。

1 个答案:

答案 0 :(得分:0)

<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)

添加数据表:widgetVar="productTable"

在你的按钮中添加:oncomplete="PF('productTable').clearFilters();"

相关问题