1
votes

I used primefaces 3.4RC1 for develop a data table with filtering by following this http://www.primefaces.org/showcase-labs/ui/datatableFiltering.jsf. 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. 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

1
please any one can give me an idea about above issue.user1705260

1 Answers

0
votes

If you want to search records based on the id you can follow this one.

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.

But sortBy option is compalsary to give in all columns. I am already developing datatable by using the above code.