[英]primefaces dataTable filtering issue
I used primefaces 3.4RC1 for develop a data table with filtering by following this http://www.primefaces.org/showcase-labs/ui/datatableFiltering.jsf . 我通过遵循以下http://www.primefaces.org/showcase-labs/ui/datatableFiltering.jsf使用primefaces 3.4RC1开发具有过滤功能的数据表。 But I have some issue.After filtering some thing it gives the records repeatedly.for an example if there is only one record,it repeats 5 times and if there are 2 records it repeats 10 times.
但是我有一个问题。过滤掉某些东西后,它会重复提供记录。例如,如果只有一条记录,它将重复5次,如果有2条记录,它将重复10次。 What is the reason for that issue?
这个问题的原因是什么?
<p:dataTable id="tableList" var="tablevar" value="#{tableBean.table}"
style="font-size: 12px; width:1310px;" widgetVar="carsTable"
emptyMessage="No recode found with given criteria" filteredValue="#{tableBean.filteredCars }"
scrollable="true" scrollHeight="450" resizableColumns="flase">
<f:facet name="header">
<p:outputPanel style="display:block; text-align:right">
<h:outputText value="Search all fields:"/>
<p:inputText id="globalFilter" onkeyup="carsTable.filter()" style="width:150px" />
</p:outputPanel>
</f:facet>
<p:column headerText="ID" width="50">
<h:outputText value="#{tablevar.id}" style="font: medium "/>
</p:column>
<p:column headerText="Country" width="50" filterBy="#{tablevar.country}" filterMatchMode="contains">
<h:outputText value="#{tablevar.country}" style="font: medium"/>
</p:column>
<p:column headerText="Country Code" width="50" filterBy="#{tablevar.country_code}" filterMatchMode="contains">
<h:outputText value="#{tablevar.country_code}" style="font: medium "/>
</p:column>
<p:column headerText="MGT" width="50" filterBy="#{tablevar.MGT}" filterMatchMode="contains">
<h:outputText value="#{tablevar.MGT}" style="font: medium "/>
</p:column>
<f:facet name="footer" id="foot">
<h:panelGrid columns="8" cellpadding="5" id="pane" >
<h:outputLabel value="Country" />
<p:inputText value="#{tableBean.c_country}" id="country" required="false" label="country" />
<h:outputLabel value="Country_Code" />
<p:inputText value="#{tableBean.c_country_code}" id="countrycode" required="false" label="countrycode" />
<h:outputLabel value="MGT" />
<p:inputText value="#{tableBean.c_MGT}" id="mgt" required="false" label="mgt" />
<p:commandButton id="loginButton" value="AddNew" update=":form:messages" actionListener="#{tableBean.addNew}" oncomplete="javascript:location.reload(true)" onstart="return myFunction3();"/>
<p:commandButton type="reset" value="Clear" oncomplete="javascript:location.reload(true)"/>
</h:panelGrid>
</f:facet>
</p:dataTable>
Thanks 谢谢
If you want to search records based on the id you can follow this one. 如果要基于ID搜索记录,可以遵循此ID。
this is the simple sample code try this one. 这是简单的示例代码,请尝试此代码。
<p:dataTable value="#{tableBean.table}" var="tablevar" >
<p:column style="width:10%;text-align:left" filterBy="#{tablevar.id}" >
<f:facet name="header">
<h:outputText value="ID" id="id" />
</f:facet>
<h:outputText value="#{tablevar.id}" />
</p:column>
<p:column style="width:20%;text-align:left" sortBy="#{tablevar.country}">
<f:facet name="header">
<h:outputText value="Customer" id="customer" />
</f:facet>
<h:outputText value="#{tablevar.country}" />
</p:column>
</p:dataTable>
you can give filterBy in only one column or multiple columns its not a problem. 您可以只在一列或多列中给filterBy一个问题。
But sortBy option is compalsary to give in all columns. 但是sortBy选项在所有列中都是强制性的。 I am already developing datatable by using the above code.
我已经在使用上面的代码开发数据表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.