2 Replies Latest reply on Jul 7, 2012 3:50 AM by Karsten Wutzke

    Text filtering on rich:dataTable using a rich:collapsibleSubTable only on current page

    Karsten Wutzke Expert

      Hello all,

       

      I have a data table with a collapsible sub table plus a data scroller:

       

      {code}<?xml version="1.0" encoding="UTF-8"?>

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

                "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

      <html xmlns="http://www.w3.org/1999/xhtml"

            xmlns:fn="http://java.sun.com/jsp/jstl/functions"

            xmlns:f="http://java.sun.com/jsf/core"

            xmlns:h="http://java.sun.com/jsf/html"

            xmlns:ui="http://java.sun.com/jsf/facelets"

            xmlns:a4j="http://richfaces.org/a4j"

            xmlns:rich="http://richfaces.org/rich">

        <h:head>

        </h:head>

        <h:body>

          <h:form>

            <rich:dataTable value="#{testBean.documentGroups}"

                            var="dg"

                            rows="4"

                            footerClass="center"

                            id="repo-tdoc-datatable">

              <f:facet name="header">

                <rich:columnGroup>

                  <rich:column>

                    <h:panelGrid columns="1" style="width: 100%;">

                      <h:outputText value="Title" />

                      <h:inputText value="#{testBean.groupSearchString}"

                                   style="width: 70px;">

                        <a4j:ajax execute="@this" render="repo-tdoc-datatable@body repo-tdoc-datascroller" event="keyup" />

                      </h:inputText>

                    </h:panelGrid>

                  </rich:column>

                  <rich:column><h:outputText value="File Name" /></rich:column>

                </rich:columnGroup>

              </f:facet>

              <rich:collapsibleSubTable value="#{dg.documents}"

                                        var="doc"

                                        rowKeyVar="rowNbr">

                <rich:column filterExpression="#{fn:containsIgnoreCase(dg.title, testBean.groupSearchString)}"

                             rowspan="#{dg.numDocuments}"

                             rendered="#{empty rowNbr or rowNbr eq 0}">

                  <h:outputText value="#{dg.title}" />

                </rich:column>

                <rich:column styleClass="left">

                  <h:outputText value=" #{doc.fileName}" />

                </rich:column>

              </rich:collapsibleSubTable>

              <f:facet name="footer">

                <rich:dataScroller id="repo-tdoc-datascroller" />

              </f:facet>

            </rich:dataTable>

          </h:form>

        </h:body>

      </html>{code}

       

      The first column allows to filter groups by a title.

       

      This looks like this in action (all four pages):

       

      Page 1Page 2Page 3Page 4
      datatable-group-search-p1-unfiltered.pngdatatable-group-search-p2-unfiltered.pngdatatable-group-search-p3-unfiltered.pngdatatable-group-search-p4-unfiltered.png

       

      Note the "Twelve" on page 4 isn't supposed to be there, but that's another story......

       

      Now when entering a simple 'n' in the search box, the search doesn't make the number of pages smaller, but it will only make each one of the four pages smaller, but not the total number of pages, like:

       

      Page 1Page 2Page 3Page 4
      datatable-group-search-p1-filtered.pngdatatable-group-search-p2-filtered.pngdatatable-group-search-p3-filtered.pngdatatable-group-search-p4-filtered.png

       

      The filter basically works, as only groups containing an 'n' are shown, however the number of pages aren't getting less (which they should). (This basically searches only the current page...)

       

      The code is very basic IMHO, but I don't see the problem.

       

      Does anybody know what I am doing wrong?

       

      Karsten

       

      PS: The TestBean used to create the documents is attached.