I looked carefully through issues/forum but did not find similar report.
I have multiple columns and use sortBy on all and filterBy on only one.
On fresh page load sortBy does not work, clicking on header is ignored.
However, if I enter a character into the filter, thereafter sorting works.
The exact same problem was reported by somebody else here:
http://stackoverflow.com/questions/5487 ... 69#6888769
This happens with data pulled from database by query, with reset per page load using:
Code: Select all
<f:view>
<f:metadata>
<f:event type="preRenderView" listener="#{electricalEnergyConsumerManager.reset}"/>
</f:metadata>
</f:view>
Code: Select all
public void reset() {
consumerBlocks = null;
..
}
Code: Select all
<p:dataTable
value="#{electricalEnergyConsumerManager.consumerBlocks}"
var="consumer"
rowEditListener="#{electricalEnergyConsumerManager.updateConsumerRow}"
>
<p:column styleClass="view-field-name" sortBy="#{consumer.name}" filterBy="#{consumer.name}">
<f:facet name="header">
Electrical energy consumer
</f:facet>
<p:cellEditor>
<f:facet name="output">
<util:view_link element="#{consumer}"/>
</f:facet>
<f:facet name="input">
<h:inputText value="#{consumer.name}"/>
</f:facet>
</p:cellEditor>
</p:column>
Code: Select all
private List<Block> consumerBlocks;
public List<Block> getConsumerBlocks() {
if (consumerBlocks == null) {
consumerBlocks = fetchConsumerBlocks();
}
return consumerBlocks;
}
public List<Block> fetchConsumerBlocks() {
if (projectManager.getProject() == null) {
return null;//TODO warn
}
return blockQuery.findElectricalEnergyConsumerBlocks(projectManager.getProject());
}
This strategy ensures do not repeat query for each JSF phase through multiple getter calls.
I had written:
If I remove the filterBy the sorting works fine ..
EDITED: this is not so, the filterBy has to be there for the sorting to work at all in my case.