2015-02-23 80 views
0

我正在使用primefaces 5.0和Weblogic應用程序服務器和JSF2.0。使用下拉列表primefaces數據表清除過濾

問題:如何清除下拉列表在p:datatable中過濾。

我的代碼:XHTML:

<p:column rowspan="3" style="text-align: center; width:80px;" 
    filterBy="#{monitorLookUpdata.status}" 
    sortBy="#{monitorLookUpdata.status}" 
    filterMatchMode="contains" filterMaxLength="9" id="statusId" 
    filterStyle="width:80%;"> 
    <f:facet name="header"> 
     <br/><br/> 
     <h:outputText value="Status" /> 
    </f:facet> 
    <f:facet name="filter"> 
     <h:selectOneMenu onchange="PF('monitorLookUp').filter()" class="ui-simple-text"> 
      <f:selectItem itemLabel="" itemValue="" noSelectionOption="true" /> 
      <f:selectItem itemLabel="Open" itemValue="Open" /> 
      <f:selectItem itemLabel="Delivered" itemValue="Delivered" /> 
      <f:selectItem itemLabel="Closed" itemValue="Closed" /> 
     </h:selectOneMenu> 
    </f:facet> 
</p:column> 

Java代碼:

FacesContext.getCurrentInstance().getExternalContext().getSessionMap().remove("filteredData"); 

回答

0
<p:column rowspan="3" style="text-align: center; width:80px;" 
              filterBy="#{monitorLookUpdata.status}" 
              filterOptions="#{monitorLookupHandler.options}" 
              sortBy="#{monitorLookUpdata.status}" 
              filterMatchMode="contains" filterMaxLength="9" id="statusId" 
              filterStyle="width:80%;"> 
              <f:facet name="header"> 
              <br/><br/> 
               <h:outputText value="Status" /> 
           </f:facet> 


             </p:column> 

和Java代碼將是:

private SelectItem[] options; 
options = new SelectItem[4]; 
     options[0] = new SelectItem(" ", " "); 
     options[1] = new SelectItem("Open", "Open"); 
     options[2] = new SelectItem("Delivered", "Delivered"); 
     options[3] = new SelectItem("Closed", "Closed"); 

現在上面的代碼按預期工作。謝謝大家。