2 Replies Latest reply on May 24, 2011 10:26 AM by Kapil Nimje

    Problem in DataTable Filtering with two columns

    Kapil Nimje Newbie

      Hi

       

      I have one datatable with thousands of data in it. I want to add the filters for more than two columns. What i want is.. I have datatable with following columns.

       

      ID, project Name , status, size, created at, modified at, etc...

       

      And also I have a search text field at the top of the datatable to serach the projects by name. When I enterd somethig in the search text I would get the matching project names in the data table. Now what we want to implement is, if I entered the numberic data in the search field, we want all the matching project names which has the numeric value as well as the IDs.

       

      Attached is the screen shot of Datatable image.

       

      Please find the below code which is working for only single column filter. How can use the same filter for more than two columns.

       

      <rich:dataTable id="data_table"

                      width="100%"

                      border="0"

                      cellspacing="0"

                      cellpadding="0"

                      headerClass="headers"

                      rowClasses="alt1,alt2"

                      var="project"

                      value="#{projectController.accountFilteredProjects}"

                      binding="#{projectController.projectDataTable}"

                      rows="10">

       

          <rich:column id="idColumn" sortBy="#{project.id}" >

              <f:facet name="header"><h:outputText value="ID"/></f:facet>

              <h:outputText value="#{project.id}"/>

         </rich:column>

       

          <rich:column id="nameColumn" sortBy="#{project.name}" filterMethod="#{projectFilterBean.filterByName}" filterValue="#{projectFilterBean.nameFilterValue}">

               <f:facet name="header"><h:outputText value="Name"/></f:facet>

               <h:outputText value="#{project.name}"/>

           </rich:column>

       

      <rich:column id="createdAtColumn" sortBy="#{project.createdAt}">

               <f:facet name="header"><h:outputText value="Created On"/></f:facet>

               <h:outputText value="#{project.createdAt}">

                   <f:convertDateTime pattern="MM/dd/yyyy"/>

               </h:outputText>

           </rich:column>

       

           <rich:column id="updatedAtColumn" sortBy="#{project.updatedAt}">

               <f:facet name="header"><h:outputText value="Last Modified"/></f:facet>

               <h:outputText value="#{project.updatedAt}">

                   <f:convertDateTime pattern="MM/dd/yyyy"/>

               </h:outputText>

           </rich:column>

       

      </rich:dataTable>

       

      If i use the same filter for the ID columns as well, still it will only returns the matching projects not the IDs.

       

      Kindly suggest.