Reputation: 2405
PrimeFaces Version: 6.0
In my data table I can sort and filter columns but not both at the same time.
Following scenario:
Column1 Column2
http://someurl.com 1
http://anotherurl.com 5
When I enter a value into the Column1
filter. Only the filtered rows are visible. Now when I click on sort of Column1
I get the following result:
Column1 Column2
0
0
Column2
is mapped to a primitive value, that explains the zero value.
As a workaround I have added:
<p:ajax event="sort" onstart="PF('mytableWidget').filter();"/>
But I can still see the above empty result for some milliseconds, before the filter()
function is executed.
<p:dataTable id="mytable" widgetVar="mytableWidget" value="#{bean.data}" var="item">
<p:column headerText="Column1" sortBy="#{item.column1}" filterBy="#{item.column1}" filterMatchMode="contains">
#{item.column1}
</p:column>
<p:column headerText="Column2" sortBy="#{item.column2}">
#{item.column2}
</p:column>
bean.data
is mapped to an ArrayList<MyDataHolder>
.
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(of = "column1")
public class MyDataHolder {
String column1;
int column2;
}
Upvotes: 0
Views: 607
Reputation: 4345
It seems to me you must make MyDataHolder
serializable;
public class MyDataHolder implements Serializable
My best bet for an elaboration is the same as here (the same applies to ViewScoped beans). ViewScoped (and broader scoped) beans must be serializable, and therefore all their attributes must be the same.
Upvotes: 2