6 Replies Latest reply on Apr 9, 2007 7:42 AM by Ilya Shaikovsky

    a4j:datatable

    gajanan more Newbie

      a4j:datatable have a facility to sort the table on the basis of data in the table

        • 1. Re: a4j:datatable
          Sergey Smirnov Master

          Ajax4jsf (a4j) has no dataTable component . Probably, you speak about the RichFaces dataTable.
          Event it is so, I still do not understand the question.

          • 2. Re: a4j:datatable
            gajanan more Newbie

            i know its rich faces component
            if i want to sort the whole table on the basis of some sequence
            that facility i want

            • 3. Re: a4j:datatable
              Ilya Shaikovsky Master

              Just right now you may only organize Ajax sorting just via a4j:command* components in headers for example. Or use tomahawk ones with ajax-ed a4j:form as shown in examples.

              Sort components for our rich table - is in our roadmap.

              • 4. Re: a4j:datatable
                Sergey Smirnov Master

                The request for enhancement has been registered in jira.
                http://jira.jboss.com/jira/browse/RF-6
                Just vote for it if you like this feature to be out-of-the-box for datatable..

                • 5. Re: a4j:datatable
                  gajanan more Newbie

                  in ur Ajax4jsf forum u sended me reply thanks for that
                  but i am not getting how i can use Command Button for sorting in dataTable if u have any example
                  plz forward that example to me

                  • 6. Re: a4j:datatable
                    Ilya Shaikovsky Master

                    the simple example:

                     <rich:dataTable value="#{capitalsBean.capitals}" var="cap" id="table">
                     <rich:column>
                     <f:facet name="header">
                     <a4j:commandLink value="name" action="#{capitalsBean.namesSort}" reRender="table"/>
                     </f:facet>
                     <h:outputText value="#{cap.name}"></h:outputText>
                     </rich:column>
                     <rich:column>
                     <f:facet name="header">
                     <a4j:commandLink value="state" action="#{capitalsBean.statesSort}" reRender="table"/>
                     </f:facet>
                     <h:outputText value="#{cap.state}"></h:outputText>
                     </rich:column>
                     </rich:dataTable>
                    
                    


                     public String namesSort() {
                     Collections.sort(capitals, new Comparator<Capital> () {
                    
                     public int compare(Capital capital, Capital capital2) {
                     return capital.getName().compareTo(capital2.getName());
                     }
                    
                     });
                     return null;
                     }
                     public String statesSort() {
                     Collections.sort(capitals, new Comparator<Capital> () {
                    
                     public int compare(Capital capital, Capital capital2) {
                     return capital.getState().compareTo(capital2.getState());
                     }
                    
                     });
                     return null;
                     }