下拉列表未显示在 primefaces 数据表列筛选框中

Dropdown list is not show in primefaces datatable column filter box

我正在使用 Jsf 2.2 和 primefaces 4.0。当我使用这段代码时一切正常。

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

然后下拉列表不显示在过滤框中,过滤不起作用--------请帮助任何人。

4.0 不支持过滤面...(查看文档,查看 blog 以查看它是何时添加的等...)

由于Filter Facets在4.0中不可用,您可以使用<p:columnfilterOptions,只需创建一个[=14]的数组=] ,使用相关值并将其放入您的 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