Primefaces DataTable RowGroup with HeaderRow : how to reverse order?

22 Views Asked by At

I'm using p:headerRow in my dataTable with a java.time.Instant field. It works fine but the rows appear in ascending order. How to reverse the order ?

<p:dataTable value="#{comptaPeriodeView.auditLines}" var="item" id="auditLines" widgetVar="auditLinesTb">                   >    
  <p:headerRow field="inventaireAudit.inventaire.creationTime" expandable="true" expanded="true">
    <p:column colspan="7" sortOrder="desc" >
      <div class="inline-flex align-items-center" style="vertical-align: middle">
        <h:outputText value="#{format.zdEuropeParis(item.inventaireAudit.inventaire.creationTime)}">
            <f:convertDateTime type="zonedDateTime" pattern="dd/MM/yyyy HH:mm:ss" />
        </h:outputText>
      </div>
    </p:column>
</p:dataTable>

Edit : Same problem with the showcase "Row Group" : how to reverse the order of the representative names ?

1

There are 1 best solutions below

0
grigouille On

I took a look at org.primefaces.component.headerrow.HeaderRowBase and there is a sortOrder value. So adding sortOrder="desc" does the trick. For example in showcase :

<p:headerRow field="representative.name"
                                  expandable="true" 
+                                 sortOrder="desc"
                                  expanded="#{customer.representative.name != 'Stephen Shaw'}">

This attribute is missing in the documentation :

https://primefaces.github.io/primefaces/13_0_0/#/components/headerrow