2016-08-23 45 views
1

我正在使用帶有過濾器和分頁的p:datatable。兩者都單獨工作,但如果我先過濾然後移動到結果的第二頁,過濾器被刪除,我看到原始數據集的第二頁。以下是我的桌子的樣子:Primefaces數據表分頁重置篩選器

<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處理同樣的問題,但它從來沒有回答。

+0

與全局過濾器測試,它的工作原理。我沒有一個coumn特定的過濾器 – Apostolos

+1

我猜想有處理列過濾器的邏輯有問題。我升級到PF 6.0並驗證問題仍然可重現。儘管如此,根據[showcase示例](http://www.primefaces.org/showcase/ui/data/datatable/lazy.xhtml)將我的表更改爲延遲加載並使用自定義DataModel的確行得通。不理想,因爲我正在處理的數據集已經被緩存了,因此我不需要延遲加載,但是它可以工作,並且沒有明顯的性能差異。 – bendicott

回答

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

+0

整個問題是分頁重置過濾器;以什麼方式手動清除過濾器列表幫助? – bendicott