DataTable: Plain sort doesn't work (require filter)
Posted: 06 Sep 2011, 12:16
Dear All,
Since last weekends, I have been trying to fix this myself, however, I couldn't..
ISSUE
I am trying to get the example in the showcase work but It doesn't. In Firebug, I can see Ajax calls get fired. In the console, I can see the sort method actually is being called. But the table remains as is.
I tried the built-in sort with String, and the custom one with Double. Neither works.
I tested it against the two releases, 2.2.1 and 3.0.M3.
Any help or insight is appreciated
SNIPPETS
Data
Table' Signature
Column' Signature
Server-side sort function
Ajax's Response Body
Since last weekends, I have been trying to fix this myself, however, I couldn't..
ISSUE
I am trying to get the example in the showcase work but It doesn't. In Firebug, I can see Ajax calls get fired. In the console, I can see the sort method actually is being called. But the table remains as is.
I tried the built-in sort with String, and the custom one with Double. Neither works.
I tested it against the two releases, 2.2.1 and 3.0.M3.
Any help or insight is appreciated
SNIPPETS
Data
Code: Select all
public List<Monthly> getMonthly() {
return ejbFacade.findAll();
}
Code: Select all
<p:dataTable var="data" value="#{monthlyController.monthly}">
Code: Select all
<p:column sortBy="#{data.volume}" sortFunction="#{monthlyController.sortByVolume}">
<f:facet name="header">
<h:outputText value="Volume" />
</f:facet>
<h:outputText value="#{data.volume}" />
</p:column>
Code: Select all
public int sortByVolume(Object a, Object b) {
Double x = (Double) a, y = (Double) b; // Casting
System.err.println("a: "+x+", b: "+y+", " + (x < y)); // Debuging
return x < y ? -1 : x == y ? 0 : 1;
}
Code: Select all
<?xml version='1.0' encoding='UTF-8'?>
<partial-response><changes><update id="j_idt7:j_idt15"><![CDATA[<tbody id="j_idt7:j_idt15_data" class="ui-datatable-data ui-widget-content"><tr id="j_idt7:j_idt15_r_0" class="ui-widget-content ui-datatable-even"><td><div class="ui-dt-c">OMCCR_IP21</div></td><td><div class="ui-dt-c">TK503.NV</div></td><td><div class="ui-dt-c">0.0</div></td><td><div class="ui-dt-c">0.0</div></td></tr><tr id="j_idt7:j_idt15_r_1" class="ui-widget-content ui-datatable-odd"><td><div class="ui-dt-c">OMCCR_IP21</div></td><td><div class="ui-dt-c">TK821.NV</div></td><td><div class="ui-dt-c">848911.93</div></td><td><div class="ui-dt-c">-845051.6567</div></td></tr><tr id="j_idt7:j_idt15_r_2" class="ui-widget-content ui-datatable-even"><td><div class="ui-dt-c">OMCCR_IP21</div></td><td><div class="ui-dt-c">TK600.NV</div></td><td><div class="ui-dt-c">3420152.496</div></td><td><div class="ui-dt-c">-3874908.887</div></td></tbody>]]></update><update id="javax.faces.ViewState"><![CDATA[-1203497821118012635:-7198452462682231682]]></update></changes></partial-response>