1 Reply Latest reply on May 18, 2012 1:14 AM by graham777

    Combining a sortBy with a filterExpression

    pzelenka00

      Hi,

       

      I'd like to use sorting and filtering on rich:dataTable. The problem is that I need sorting arrows to be on the forst row next to column caption not on the second row.

      Can anybody help?

       

      Thanks

       

      Pavel

       

      table.png

       

       

      <rich:dataTable id="reklamacetable" value="#{reklamaceBean.reklamaceList}" binding="#{reklamaceBean.htmlDataTable}" 
                                  var="rekl" rows="20" onclick="reRenderTable();">
                      <f:facet name="header">
                          <rich:columnGroup rendered="#{sessionBean.reklamaceMK}">
                              <rich:column colspan="10">
                                  <a4j:form>
                                      <h:panelGrid columns="4">
                                          <h:outputText value="Zobrazit reklamace zákaznického centra:"/>
                                          <h:selectBooleanCheckbox value="#{sessionBean.reklamaceMKZCFilter}">
                                              <a4j:support event="onchange" reRender="reklamacetable"/>
                                          </h:selectBooleanCheckbox>
                                      </h:panelGrid>
                                  </a4j:form>
                              </rich:column>
                          </rich:columnGroup>
                          <rich:columnGroup rendered="#{sessionBean.reklamaceMK or sessionBean.reklamaceZC}">
                              <rich:column colspan="10">
                                  <a4j:form>
                                      <h:panelGrid columns="4">
                                          <h:outputText value="Zobrazit nevyřízené reklamace inspektorů:"/>
                                          <h:selectBooleanCheckbox value="#{sessionBean.reklamaceNevyrizeneFilter}">
                                              <a4j:support event="onchange" reRender="reklamacetable"/>
                                          </h:selectBooleanCheckbox>
                                      </h:panelGrid>
                                  </a4j:form>
                              </rich:column>
                          </rich:columnGroup>
                          <rich:columnGroup>
                              <rich:column>
                                  <h:outputText value="Datum"/>
                              </rich:column>
                              <rich:column sortable="true">
                                  <h:outputText value="ID"/>
                              </rich:column>
                              <rich:column>
                                  <h:outputText value="Divize"/>
                              </rich:column>
                              <rich:column>
                                  <h:outputText value="Okrsek"/>
                              </rich:column>
                              <rich:column>
                                  <h:outputText value="Typ"/>
                              </rich:column>
                              <rich:column>
                                  <h:outputText value="Stav"/>
                              </rich:column>
                              <rich:column>
                                  <h:outputText value="Adresa"/>
                              </rich:column>
                              <rich:column>
                                  <h:outputText value="Popis"/>
                              </rich:column>
                              <rich:column>
                                  <h:outputText value="Vyjádření"/>
                              </rich:column>
                              <rich:column>
                                  <h:outputText value=""/>
                              </rich:column>
                          </rich:columnGroup>
                      </f:facet>
                      <rich:column sortBy="#{rekl.reklamaceDatum}">
                          <h:outputText value="#{rekl.reklamaceDatum}">
                              <f:convertDateTime timeZone="Europe/Prague" pattern="dd.MM.yyyy" />
                          </h:outputText>
                      </rich:column>
                      <rich:column sortBy="#{rekl.id}" filterExpression="#{fn:containsIgnoreCase(rekl.id, sessionBean.reklamaceCisloFilterValue)}">
                          <f:facet name="header">
                              <h:inputText id="freklid" value="#{sessionBean.reklamaceCisloFilterValue}" onclick="Event.stop(event);" style="width:40px">
                                  <a4j:support event="onkeyup" reRender="reklamacetable" ignoreDupResponses="true" oncomplete="setCaretToEnd(event)"/>
                              </h:inputText>
                          </f:facet>
                          <h:commandLink value="#{rekl.id}" action="detail">
                              <f:setPropertyActionListener value="#{rekl}" target="#{sessionBean.reklamace}"/>
                          </h:commandLink>
                      </rich:column>
                      
                      .....
      
      
        • 1. Re: Combining a sortBy with a filterExpression
          graham777

          Hi,

           

          I am doing it like this:

           

           

           

           

           

           

           

           

           

           

           

           

           

           

           

           

           

           

           

          <rich:column id="firstName" width="120px" sortBy="#{varCustomerData.firstName}" sortOrder="#{customersDataView.sortsOrders['firstName']}"

           

                filterValue="#{customersDataView.firstNameFilter}" filterExpression="#{fn:containsIgnoreCase(varCustomerData.firstName, customersDataView.firstNameFilter)}">

           

               <f:facet name="header">

           

                    <h:panelGrid columns="2">

           

                         <a4j:commandLink execute="@this" value="First Name" render="mainTable" action="#{customersDataView.sortTable}">

           

                              <f:param name="sortProperty" value="firstName" />

           

                         </a4j:commandLink>

           

                         <h:graphicImage alt="decr" name="sort_decrease.png" library="images"

           

                                   rendered="#{customersDataView.sortsOrders['firstName']=='descending'}" />

           

                         <h:graphicImage alt="incr" name="sort_increase.png" library="images"

           

                                   rendered="#{customersDataView.sortsOrders['firstName']=='ascending'}" />

           

                    </h:panelGrid>

           

                    <h:inputText id="firstNameFilter" style="display:block;" value="#{customersDataView.firstNameFilter}" label="First Name Filter">

           

                    </h:inputText>

           

               </f:facet>

           

               <h:outputText value="#{varCustomerData.firstName}" />

           

          </rich:column>

           

           

          This renders in the following manner with sorting arrows and then the filter box underneath:

          Capture2.PNG