0
votes

I migrated from PrimeFaces 6.1 to 10.0.0 and now sortBy of every p:dataTable I have in my project doesn't work.

An example of my p:dataTable:

<p:dataTable widgetVar="truckListTable" id="truckListTable" var="truck" value="#{truckList.trucks}"
    sortBy="#{truck.code}" sortMode="single" filteredValue="#{truckList.filteredTrucks}" paginator="true"
    paginatorPosition="top" rows="20" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">
    ...
    <p:column sortBy="#{truck.plate}" filterBy="#{truck.plate}" filterMatchMode="contains">
        <h:outputText value="#{truck.plate}" />
    </p:column>
    ...
</p:dataTable>

I defined truck variable as follow in my bean truckList:

private List<Map> trucks;

public List<Map> getTrucks() {
    return trucks;
}

public void setTrucks(List<Map> trucks) {
    this.trucks = trucks;
}

My problem is when I click the column header, the table rows are not sorted.

filterBy works fine, but sortBy no. Where am I doing wrong?

1

1 Answers

2
votes

Documentation states that sortBy expects a single or a collection of SortMeta. This is also mentioned in the from 8 to 10 migration guide.

So, either provide a SortMeta from your bean or simply add sortOrder to the p:column of the "code".

SortMeta can be created like:

SortMeta.builder().field("code").order(SortOrder.ASCENDING).build();

See also: