2 Replies Latest reply on Sep 7, 2009 6:58 PM by Nick Belaevski

    filterBy on dataTable not updating dataScroller

    Jason Hopkins Newbie

      I'm using a datatable with filterBy and a datascroller. All is fine, apart from if the datascroller shows 5 pages and I enter something into the filter so there are now only have 5 rows, the datascroller still says 5 pages.

      When this happens the "Add Tutor" button in the header and the records per page drop down stops responding to user input. I found that anything that causes the datascroller to re-render fixes the problem.

      I've tried many, many things to fix this and found that if I wrap the whole table in a <a4j:outputPanel ajaxRendered="true"> everything works fine, but the filter input boxes loose focus after filtering. Code below, if anyone can see what I've done wrong I'll be very greatful, this has been driving me crazy!

       <a4j:form id="tutorForm">
       <rich:dataTable id="tutorTable" width="100%"
       value="#{AdminTutorBean.tutorModel}" var="tutor"
       rows="#{AdminTutorBean.recordsPerPage}" columnsWidth="25%,25%,40%,20%">
      
       <f:facet name="header">
       <h:panelGrid columns="2" width="100%"
       columnClasses="leftAlign, rightAlign">
       <h:outputText value="Tutors" />
       <h:panelGroup>
      
       <h:outputText value="Tutors per page: " />
      
       <a4j:region>
      
       <h:selectOneMenu value="#{AdminTutorBean.recordsPerPage}">
      
       <f:selectItem itemLabel="5" itemValue="5" />
       <f:selectItem itemLabel="10" itemValue="10" />
       <f:selectItem itemLabel="15" itemValue="15" />
       <f:selectItem itemLabel="20" itemValue="20" />
       <f:selectItem itemLabel="30" itemValue="30" />
       <f:selectItem itemLabel="40" itemValue="40" />
       <f:selectItem itemLabel="50" itemValue="50" />
      
       <a4j:support event="onchange" reRender="tutorTable" />
      
       </h:selectOneMenu>
      
       </a4j:region>
      
       </h:panelGroup>
       </h:panelGrid>
       </f:facet>
      
       <rich:column sortBy="#{tutor.firstName}"
       filterBy="#{tutor.firstName}" filterEvent="onkeyup">
       <f:facet name="header">
       <h:outputText value="First Name" />
       </f:facet>
       <h:outputText value="#{tutor.firstName}" />
       </rich:column>
      
       <rich:column sortBy="#{tutor.surname}" filterBy="#{tutor.surname}"
       filterEvent="onkeyup">
       <f:facet name="header">
       <h:outputText value="Surname" />
       </f:facet>
       <h:outputText value="#{tutor.surname}" />
       </rich:column>
      
       <rich:column>
       <f:facet name="header">
       <h:outputText value="Description" />
       </f:facet>
       <h:outputText value="#{tutor.shortDescription}" />
       </rich:column>
      
       <rich:column>
       <f:facet name="header">
       <a4j:commandButton value="Add Tutor"
       action="#{AdminTutorBean.setUpForAdd}"
       reRender="tutorForm,addEditForm" />
       </f:facet>
       <a4j:commandButton value="Edit" reRender="addEditForm"
       action="#{AdminTutorBean.setUpForEdit}" />
       <a4j:commandButton value="Delete"
       action="#{AdminTutorBean.setUpForDelete}"
       reRender="tutorForm,confirmDeleteForm" />
       </rich:column>
      
       <f:facet name="footer">
       <rich:datascroller id="tutorTablePager" maxPages="15" />
       </f:facet>
      
       </rich:dataTable>
      
       </a4j:form>