4 Replies Latest reply on Mar 17, 2011 9:32 AM by meszias

    ExtendedDataTable don't change rowcount on filter

    meszias

           See, i've developed some pagination with ExtendedDataTable. It worlked very well, and i improved some stuff on my Grid layout. If you see the attached file, in the footer, at left has 3 numbers: the first result, the last and the total results. When i use the filter with pagination, no problem, my pagination brings me the total of results when I filter an list. If I use the internal filter, without pagination, i doesnt found an way to discover how many results the filtered data has. If i use binding it always show me the total registers of the original list, but not the total registers who i see.

           I know it returns correctly to me the total pages only, and the current, but not the total, thats my code for the footer, the magedbean for the footer.

       

       

      <ui:fragment xmlns:rich="http://richfaces.org/rich"             xmlns:h="http://java.sun.com/jsf/html"
                   xmlns:f="http://java.sun.com/jsf/core"
                   xmlns:a4j="http://richfaces.org/a4j"
                   xmlns:ui="http://java.sun.com/jsf/facelets">
          <h:panelGrid columns="2" styleClass="tabelarodape" style="width: 100%;"  id="pgscroller">
              <ui:param name="totalReg" value="#{mb.rowCount}"/>
              <ui:param name="regPerPage" value="#{mb.rows}"/>
              <ui:param name="dataTableSource" value="#{empty tableId ? 'tabela' : tableId}"/>
              <h:panelGrid columns="2" styleClass="tabelapagina">
                  <rich:datascroller id="ds" for="#{dataTableSource}" immediate="true" binding="#{mb.datascr}" pagesVar="totalPages" align="right" pageIndexVar="currpage"  page="#{mb.scrollerPage}" >
                      <f:facet name="pages">
                          <h:panelGroup>                        
                              <h:outputText value="Página "/> #The page selector
                              <h:inputText onchange="javascript:if(this.value.length>0) {document.getElementById(jQuery(this).closest('div[id$=ds]').attr('id')).component.switchToPage(this.value);} else {return false;}" disabled="#{totalPages == 1}"
                                           onkeyup="javascript:somente_numero(this, #{totalPages});" value="#{mb.scrollerPage}" size="2" id="sc1">
                              </h:inputText>                        
                              <h:outputText value="de  #{totalPages}" id="totpages"/>                        
                          </h:panelGroup>
                      </f:facet>
                  </rich:datascroller>
                  <h:selectOneMenu styleClass="selectrodape" value="#{mb.rows}">
                      <f:selectItems value="#{listfactory.listMap['ROWS']}"/>
                      <a4j:support event="onchange" reRender="#{dataTableSource}, pgscroller">
                          <f:setPropertyActionListener target="#{mb.scrollerPage}" value="1"/>
                      </a4j:support>
                  </h:selectOneMenu>
              </h:panelGrid>
              <h:outputText style="float: right;" value="Ver #{currpage*regPerPage - regPerPage + 1} - #{currpage*regPerPage - (currpage*regPerPage > totalReg ? currpage*regPerPage - totalReg: 0)} de #{totalReg}"></h:outputText> #Info about, first page row, last page row, total rows.
          </h:panelGrid>
      </ui:fragment>
      
      

       

      Every time i filter or change the list on paged version i use: 

       

      public class Acessorio extends AbstractScrollerBean

      ...

      List<Cadacess> listaobj

      ...

          @Override

          public Integer getRowCount(){

              return listaobj.size();

          }

       

      And thats my scroller data:

       

      public abstract class AbstractScrollerBean implements Serializable {

          private Integer rows = ControladorGen.linhasPorPaginaInicial;

          private Integer scrollerPage = 1;

          private String state;

          private String handleValue;

       

      (with some gets and sets)

       

       

        • 1. ExtendedDataTable don't change rowcount on filter
          ilya_shaikovsky

          I do not see the code of dataTable but if you using just built-in filtering - update needed additional elements after filtering using reRender attribute on the table.

          • 2. ExtendedDataTable don't change rowcount on filter
            meszias

            In case of using built-in filtering is my problem. The dataTable reRender the rich:datascroller , every time the filters are changed the data about pages are updated, but not the information about the number of results the built-in got after filtering.

            I would like to know where this built-in filter is, id it into the renderer ? becaouse i couldn't find. I tried to search inside the component, but everywhere it shows me only the full number of results into the initial List.

            • 3. ExtendedDataTable don't change rowcount on filter
              ilya_shaikovsky

              if you just pointing the table to the list and using built-in sorting/filtering - it's actually expected result because the table wraps it to data model automatically and performs the filtering/sorting under wrapped model. Component could not be responsible for doing such changes in original list. So original list size is not actually changed. So you should implement ExtendedDataModel properly in order to have control under the filtered/sorted data actually. Two samples are in RF 3.3.3 richfaces-demo application for dataTable component (ExtendedDatamodel and ModifiableDataModel. The second should be used in your case as sorting and filtering used). http://www.jboss.org/richfaces/demos - info about demos sources.

              • 4. ExtendedDataTable don't change rowcount on filter
                meszias

                So i cant access this modified this modified wrapped model ? i guess this has the total filtered rows i need. Or it stays between the built-in component and the view component ?