2015-02-10 70 views
3

我正在使用Jsf 2.2和primefaces 4.0。當我使用這個代碼時一切正常。下拉列表不顯示在primefaces數據表列過濾器框中

<p:column headerText="Status" filterBy="#{List_request.rechargeStatusName}" filterMatchMode="contains" > 

      <h:outputText value="#{List_request.rechargeStatusName}" /> 
</p:column> 

但是當我嘗試在此列中的過濾器框中加載下拉列表時。 而寫這樣的代碼

<p:column headerText="Status" filterBy="#{List_request.rechargeStatusName}" filterMatchMode="contains" > 
          <f:facet name="filter"> 
           <p:selectOneMenu value="#{List_request.rechargeStatusName}" onchange="PF('reTab').filter()"> 
            <f:selectItem itemLabel="-Select One-" itemValue="#{null}" noSelectionOption="true" /> 
            <f:selectItems value="#{allRequestDetailsBean.rechargeStasusNameList}" /> 
           </p:selectOneMenu> 
          </f:facet> 
          <h:outputText value="#{List_request.rechargeStatusName}" /> 
      </p:column> 

然後下拉列表中沒有過濾箱和過濾顯示不工作-------- Plase幫助任何人。

回答

2

過濾方面不是在4.0支持...(查看文檔,檢查blog看的時候加入它等)

+0

感謝------------- Kukeltje – Shihab 2015-02-10 11:52:11

1

由於過濾切面不可用4.0,你可以使用<p:columnfilterOptions,剛剛創建的SelectItem[]陣列,相關的值,並將其放置在你的filterOptions

例如:

<p:column filterBy="#{car.manufacturer}" 
    headerText="Manufacturer" footerText="exact" 
    filterOptions="#{tableBean.manufacturerOptions}" 
    filterMatchMode="exact"> 
    <h:outputText value="#{car.manufacturer}" /> 
</p:column> 


private SelectItem[] manufacturerOptions; 

...

manufacturers = new String[10]; 
    manufacturers[0] = "Mercedes"; 
    manufacturers[1] = "BMW"; 
    manufacturers[2] = "Volvo"; 
    manufacturers[3] = "Audi"; 
    manufacturers[4] = "Renault"; 
    manufacturers[5] = "Opel"; 
    manufacturers[6] = "Volkswagen"; 
    manufacturers[7] = "Chrysler"; 
    manufacturers[8] = "Ferrari"; 
    manufacturers[9] = "Ford"; 

public SelectItem[] getManufacturerOptions() { 
    return manufacturerOptions; 
} 

查看展櫃DataTable - Filtering


Read more in the docs

+0

感謝丹尼爾完整的例子。有用 。但從哪個版本開始可以使用Filter Facets請通知我。再次感謝 – Shihab 2015-02-10 11:19:10

+0

可能自PF-5(根據以下http://blog.primefaces.org/?p=3084) – Daniel 2015-02-10 12:10:46

+0

由於PF-5可用篩選器構面。感謝Deniel – Shihab 2015-02-10 13:24:44