Reputation: 213
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?
Upvotes: 2
Views: 4363
Reputation: 49
To me issue was solved by wrapping dataTable in the form tag:
<h:form id="applicationsForm">
<p:dataTable id="applicationsTable" var="applicationValue" value="#{applicationsListBean.applications}" sortMode="single" >
Upvotes: 0
Reputation: 46
Had the same issue, which cost me several hours.
Stumbled across this thread: https://github.com/primefaces/primefaces/issues/7232#issuecomment-822529549
Changing javax.faces.STATE_SAVING_METHOD
to server
fixed the issue.
Try adding/replacing in your web.xml
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
Upvotes: 1
Reputation: 20178
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:
Upvotes: 2