2 Replies Latest reply on May 9, 2014 10:03 PM by leonelfl

    Datatable with sort, filter and datascroller => issue

    nicolas-vignal

      Hello,

       

      I am trying to setup a rich:dataTable with filter / sort and datascroller. With the following summary of code, it's working as expected :

       

      ...
                      <rich:column filterBy="#{pdv.produitId}" sortable="true"
                          sortBy="#{pdv.produitId}">
                          <f:facet name="header">
                              <h:outputText value="#{Messages.Dialogue_FiltreTri}" />
                          </f:facet>
                          <h:outputText value="#{pdv.produitId}" />
                      </rich:column>
      ...
                      <f:facet name="footer">
                          <rich:datascroller renderIfSinglePage="false" maxPages="5" id="ds1"
                              reRender="dt1, genericErrorPopupContent" />
                      </f:facet>
                     
      But my needs are a little bit different. Built-in filter use the startWith method and I would like to use an equals method.
      To do that, I tried several method but each time, I have a behaviour that I cannot correct.
      So I decided to update my code step by step.

       

      First test with an external filter :

       

                      <rich:column sortable="true" sortBy="#{pdv.produitId}"
                          filterMethod="#{pageDeVenteBackingBean.doIdProduitFilter}">
                          <f:facet name="header">
                              <h:outputText value="#{Messages.Dialogue_FiltreTri}" />
                              <h:inputText value="#{pageDeVenteBackingBean.idProduitFilter}"
                                  maxlength="3" size="3">
                                  <a4j:support event="onkeyup" ignoreDupResponses="true"
                                      requestDelay="700" reRender="dt1" focus="input" />
                              </h:inputText>
                          </f:facet>
                          <h:outputText value="#{pdv.produitId}" />
                      </rich:column>   
                      ...
                      <f:facet name="footer">
                          <rich:datascroller renderIfSinglePage="false" maxPages="5" id="ds1"
                              reRender="dt1, genericErrorPopupContent" />
                      </f:facet>
                     
      In this case, when I click on the inputText, I cannot enter any value and the sorted function is launched
      If I remove the sortable and sortBy attribute, filter is working except when I use the datascroller.
      When I click on the datascoller, filter value is deleted.
      I can correct the sort behaviour If I duplicate rich:column, one for the filter, one to sort data. In this case, the datascroller issue is still there.
             
                          <f:facet>
                              <rich:column>
                                  <h:outputText value="#{Messages.Dialogue_Filtre} : " />
                                  <h:inputText value="#{pageDeVenteBackingBean.idProduitFilter}"
                                      maxlength="3" size="3">
                                      <a4j:support event="onchange" reRender="dt1" />
                                  </h:inputText>
                              </rich:column>
                          </f:facet>
                      <rich:column breakBefore="true" sortable="true" sortBy="#{pdv.produitId}"
                          filterMethod="#{pageDeVenteBackingBean.doIdProduitFilter}">
                          <f:facet name="header">
                              <h:outputText value="#{Messages.Dialogue_Tri}" />
                          </f:facet>
                          <h:outputText value="#{pdv.produitId}" />
                      </rich:column>
                      ...
                      <f:facet name="footer">
                          <rich:datascroller renderIfSinglePage="false" maxPages="5" id="ds1"
                              reRender="dt1, genericErrorPopupContent" />
                      </f:facet>

       

      Software version used :
      jsf 1.2_09-b02
      facelets 1.1.14
      richfaces 3.3.3 Final
      jdk 1.6.0_07
      tomcat 6.0

       

      In advance thanks for your advice

       

      Best Regards

       

        Nicolas Vignal

        • 1. Re: Datatable with sort, filter and datascroller => issue
          nicolas-vignal

          Hello,

           

          I finaly found a solution :

          - datascroller is an Ajax component

           

          I used the method a4j:keepalive to save my filter in Ajax

           

          Best regards

           

            Nicolas Vignal

          • 2. Re: Datatable with sort, filter and datascroller => issue
            leonelfl

            I find this solution:

             

            <rich:column id="c1"  filterMethod="#{ManagerPageBean.filterVar}"  width="200px" sortable="true" sortBy="#{var.valor}">

                   <f:facet name="header">

                        <h:inputText value="#{ManagerPageBean.campoFilter}"  onclick="Event.stop(event)">

                             <a4j:support event="onkeyup" ignoreDupResponses="true"   requestDelay="700" reRender="dt1,ds1" focus="input" />

                        </h:inputText>

                   </f:facet>

                   <h:outputText value="#{var.valor}" />

            </rich:column>

             

            The filter, sorted function and the value are oK.