tags:

views:

31

answers:

2

Is it possible to sort a datatable by a specific column when it first loads? Or does it need to be done using the DAO? When I put on ORDER BY in my SQL in my DAO, no data at all is returned in the datatable

A: 

This my datatable

      <rich:dataTable value="#{myBean.productList}"
                    var="product"
                    >                           


                    <f:facet name="header">
                        <rich:columnGroup>
                            <rich:column><h:outputText value="" /></rich:column>                
                            <rich:column><h:outputText value="Prod Name" /></rich:column>
                            <rich:column><h:outputText value="Prod User" /></rich:column>
                            <rich:column><h:outputText value="Prod Pword" /></rich:column>
                            <rich:column><h:outputText value="Prod Last Access Date" /></rich:column>                       

                        </rich:columnGroup>

                      </f:facet>

                    <rich:column sortBy="#{product.status}" ><h:graphicImage value="images/status#{product.status}.png"/></rich:column>
                    <rich:column sortBy="#{product.name}"><h:outputText value="#{product.name}" /></rich:column>
                    <rich:column sortBy="#{product.uname}"><h:outputText value="#{currentMusicBox.username}" /></rich:column>
                    <rich:column sortBy="#{product.pword}"><h:outputText value="#{product.pword}" /></rich:column>
                    <rich:column sortBy="#{product.lastaccess}"><h:outputText value="#{product.lastaccess}" converter="customDateTimeConverter"/></rich:column>                                                                            

               </rich:dataTable>

When the datatable loads I'd like for it to be sorted by last access date first rather than me having to click the column after it loads

En-Motion
A: 

Solved it used the sortOrder="DESCENDING" or "ASCENDING" on the column you wish to have sorted when datatable first loads

En-Motion