java JSF 数据表过滤器示例
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15759936/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JSF DataTable filter example
提问by zuri
I have the following code.
我有以下代码。
<p:column headerText="Bank">
<f:facet name="header">
<p:selectOneMenu id="bank" value="#{reportsExecHistManagedBean.bankList}">
<f:selectItem itemLabel="Select Bank" itemValue="" />
<f:selectItems value="#{reportsExecHistManagedBean.bankList}"/>
</p:selectOneMenu>
</f:facet>
<h:outputText value="#{tr.bank}" />
</p:column>
how to enable filtering here, e.i when user select any selectItem, datatable shows filtered values. Also i have lazyLoading in my table. I do not want to following code
如何在此处启用过滤,即当用户选择任何选择项时,数据表会显示过滤后的值。我的桌子上也有lazyLoading。我不想遵循代码
<p:column headerText="Bank" filterBy="#{tr.bank}" style="text-align:left; width:10px;" filterOptions="#{reportsExecHistManagedBean.bankList}" filterMatchMode="exact">
<h:outputText value="#{tr.bank}"/>
</p:column>
回答by AurA
Filter is a very powerful feature available in primefaces datatable, you can use a filter as the example shown
过滤器是 primefaces 数据表中一个非常强大的功能,您可以使用过滤器作为示例
For a column filter it goes like this
对于列过滤器,它是这样的
<p:column id="modelColumn" filterBy="#{car.model}"
headerText="Model" footerText="contains"
filterMatchMode="contains">
filterMatchMode can have values :- "startsWith"(default), "endsWith", "contains" and "exact"
filterMatchMode 可以有值:-“startsWith”(默认)、“endsWith”、“contains”和“exact”
You can know more about datafilters from the official website as under http://www.primefaces.org/showcase/ui/datatableFiltering.jsf
您可以在http://www.primefaces.org/showcase/ui/datatableFiltering.jsf下的官方网站上了解有关数据过滤器的更多信息