13 Replies Latest reply on Nov 16, 2007 2:38 AM by dmitry.demyankov

    Making a table sortable.

    cbrands

      The rich:datatable component has no sortable columns. I need a table with sortable columns so I wondered if I can make a sortable column in the following way.

      <rich:dataTable>
       <rich:column sortable="true">
       <h:outputText value="columnA></h:outputText>
       </rich:column>
       <rich:column>
       <h:outputText value="columnB></h:outputText>
       </rich:column>
      </rich:dataTable>
      

      Wil something like this work and if columnA gets sorted does columnB change accordingly?
      Thanks

        • 1. Re: Making a table sortable.
          dmitry.demyankov

          Nope, sortable="true" doesn't work in dataTable. You should implement your own sort methods..

          • 2. Re: Making a table sortable.
            tjakopec

            But, it will work in 3.2.0?

            • 3. Re: Making a table sortable.
              cbrands

              Thanks dmitry,
              Making sort methods is no problem. But how can I make rich:dataTable run them when They have to? There is a onRowClick attribute but unfortunally no onColumnClick attribute :-(

              • 4. Re: Making a table sortable.
                dmitry.demyankov

                2 tjakopec
                It's in the road map for 3.2.0 but will it be implemented or not is a question to developers :)

                2 cbrands
                I just made headers in columns as a4j:commandLink and sort column when it is clicked.

                • 5. Re: Making a table sortable.
                  cbrands

                  dmitry
                  You mean something like this?


                  <rich:dataTable id="mytable">
                  <rich:column>
                  <a4j:commandLink reRender="mytable"
                  action="mybean.mySortMethod">
                  <h:outputText value="columnA></h:outputText>
                  </rich:column>
                  <rich:column>
                  <h:outputText value="columnB></h:outputText>
                  </rich:column>
                  </rich:dataTable>


                  sorry to ask so many questions I am new to richfaces.
                  thanks for your help

                  • 6. Re: Making a table sortable.
                    dmitry.demyankov

                    I mean something like this

                    <rich:column>
                     <f:facet name="header">
                     <a4j:commandLink value="column 1" action="#{bean.sortMethod}" reRender="myTable"/>
                     </f:facet>
                     <h:outputText value="#{item}">
                    </rich:column>


                    You can also add a4j:actionparam to commandLink pass some parameters.

                    Hope it helps :)

                    • 7. Re: Making a table sortable.
                      cbrands

                      I understand.

                      Thank you for all your help.

                      • 8. Re: Making a table sortable.
                        tjakopec

                         

                        "dmitry.demyankov" wrote:
                        I mean something like this

                        <rich:column>
                         <f:facet name="header">
                         <a4j:commandLink value="column 1" action="#{bean.sortMethod}" reRender="myTable"/>
                         </f:facet>
                         <h:outputText value="#{item}">
                        </rich:column>


                        You can also add a4j:actionparam to commandLink pass some parameters.

                        Hope it helps :)


                        I now how to implemented sortable and I said its not hard, but that OK if you have one or two datatable with the simple entity (3-4 attributes). We would like to get generic sortable because we have lots of datatables and in each one off them we show entity.entity.entity.attribute. Two months ago there was discussion on subject and conclusion was that is not so hard to implement generic sortable but its only a question will developers wanna implement generic sortable in datatable because they already did in r:scrollableDataTable.

                        • 9. Re: Making a table sortable.
                          dmitry.demyankov

                          Well, in that case you should wait until 3.2.0 release - there's a sortable dataTable in road map for that release.. otherwise you probably should write your own implementation of dataTable..

                          • 10. Re: Making a table sortable.
                            tjakopec

                             

                            "dmitry.demyankov" wrote:
                            Well, in that case you should wait until 3.2.0 release - there's a sortable dataTable in road map for that release.. otherwise you probably should write your own implementation of dataTable..


                            Its OK, I am waiting for 3.2.0., I trying to build it manually but currently there are two thing that i not finished
                            1. http://jira.jboss.com/jira/browse/RF-1340
                            2. build failed on Skins part...

                            • 11. Re: Making a table sortable.
                              dmitry.demyankov

                              I haven't tried working 3.2.0 release. I usually stick to latest stable version.

                              • 12. Re: Making a table sortable.
                                tjakopec

                                 

                                "dmitry.demyankov" wrote:
                                I haven't tried working 3.2.0 release. I usually stick to latest stable version.


                                Agree, we also working with 3.1.3, but every night I build 3.2.0 hoping to work and get sortable on datatable :)

                                • 13. Re: Making a table sortable.
                                  dmitry.demyankov

                                  I see, good luck then :)