我使用的是primefaces 5.0和Weblogic应用服务器以及JSF2.0。
问题:如何清除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 :(得分: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 Code将是:
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");
现在上面的代码按预期工作。谢谢大家。