5 Replies Latest reply on Jul 27, 2009 8:40 PM by bwilliam

    scrollableDataTable initial sort value

    bwilliam

      Hello,
      I'm having a problem with rich:scrollableDataTable. All I want to do is specify a column to render in DESCENDING order... very simple but I can't get it to work the table is declared as follows:


      <rich:scrollableDataTable id="${id}notesTable" var="note"
       value="${noteActionEntity.notes}"
       selection="${noteActionEntity.noteSelection}"
       binding="${noteActionEntity.noteDataTable}" sortMode="single"
       selectionMode="single" height="290px" width="720px">
      
      
       <rich:column width="180px" styleClass="centre" sortExpression="noteSourceParty.formalPartyName">
       <f:facet name="header">
       <h:outputText value="#{messages.noteLodgedByLabel}" />
       </f:facet>
       <t:outputText value="${note.noteSourceParty.formalPartyName}" />
       </rich:column>
       <rich:column width="160px" styleClass="centre" sortExpression="messageDate" sortOrder="DESCENDING">
       <f:facet name="header">
       <h:outputText value="#{messages.noteDateLodgedLabel}" />
       </f:facet>
       <h:outputText value="${note.messageDate}" />
       </rich:column>
       <rich:column width="256px" sortExpression="messageText">
       <f:facet name="header">
       <h:outputText value="#{messages.messagePreviewLabel}" />
       </f:facet>
       <t:outputText value="${note.messageText}" />
       </rich:column>
       <rich:column width="100px" sortExpression="messageAck">
       <f:facet name="header">
       <h:outputText value="#{messages.acknowledgedLabel}" />
       </f:facet>
       <t:outputText value="${note.messageAck}" />
       </rich:column>
      </rich:scrollableDataTable>
      
      
      I am trying to get the noteLodged column to sort descending on start up but it always sorts ascending. NOte the use of the sortExpression and the sortOrder attributes. A click on the header works fine to toggle the sort.
      
      Thanks for any help.
      
      Brett
      


        • 1. Re: scrollableDataTable initial sort value
          ilya_shaikovsky
          • 2. Re: scrollableDataTable initial sort value
            bwilliam

            Ok, not implemented yet, thanks for clearing that up.
            Brett

            • 3. Re: scrollableDataTable initial sort value
              konstantin.mishin
              • 4. Re: scrollableDataTable initial sort value
                ilya_shaikovsky

                yup.. sorry missed the point. Now you could see info in issue. And I'll create an article in nearest days.. Thanks for your point!

                • 5. Re: scrollableDataTable initial sort value
                  bwilliam

                  A quick summary of the solution:

                  The scrollable data table has a binding attribute 'sortOrder' which binds to a bean property of type SortOrder.

                  
                   <rich:scrollableDataTable id="${id}notesTable" var="note"
                   value="${noteActionEntity.notes}"
                   selection="${noteActionEntity.noteSelection}"
                   binding="${noteActionEntity.noteDataTable}"
                   sortMode="single" selectionMode="single" sortOrder="${noteActionEntity.order}" height="172px" width="570px">
                  
                  
                   <rich:column width="170px" styleClass="centre" sortExpression="noteSourceParty.formalPartyName">
                   <f:facet name="header">
                   <h:outputText value="#{messages.noteLodgedByLabel}" />
                   </f:facet>
                   <t:outputText value="${note.noteSourceParty.formalPartyName}" />
                   </rich:column>
                   <rich:column width="140px" styleClass="centre" sortExpression="messageDate" >
                   <f:facet name="header">
                   <h:outputText value="#{messages.noteDateLodgedLabel}" />
                   </f:facet>
                   <h:outputText value="${note.messageDate}" />
                   </rich:column>
                   <rich:column width="136px" sortExpression="messageText">
                   <f:facet name="header">
                   <h:outputText value="#{messages.notePreviewLabel}" />
                   </f:facet>
                   <t:outputText value="${note.messageText}" />
                   </rich:column>
                  
                   <rich:column width="100px" sortExpression="messageAck">
                   <f:facet name="header">
                   <h:outputText value="#{messages.acknowledgedLabel}" />
                   </f:facet>
                   <t:outputText value="${note.messageAck}" />
                   </rich:column>
                  
                  
                   </rich:scrollableDataTable>
                  
                  



                  And in the bean itself:

                  ...

                   /**
                   * A binding attribute on the note data table used to control the initial sort order.
                   */
                   private SortOrder order = new SortOrder();
                  
                  
                  
                  
                   public AbstractNoteControllerBean() {
                   // Initially sort on the messageDate column false indicates DESCENDING.
                   // messagedate corresponds to a property on the Datatype that is being
                   // iterated on in the table
                   SortField[] fields = {new SortField("messageDate", false)};
                   order.setFields(fields);
                  
                  
                  
                   }
                  
                   /**
                   * @return the order
                   */
                   public SortOrder getOrder() {
                   return order;
                   }
                  
                   /**
                   * @param order the order to set
                   */
                   public void setOrder(SortOrder order) {
                   this.order = order;
                   }