Note that there are some explanatory texts on larger screens.

plurals
  1. POColumn in gwt celltable doesn't sort
    text
    copied!<p>I want to add sorting for column in celltable with help of ListHandler. But it doesn't sort. I don't understand why it doesn't work. My code is based on GWT tutorial. Please suggest me something.</p> <p>Contract.java</p> <pre><code>public class Contract implements Serializable { private int contId; private String contOrgName; //getters and setters... } </code></pre> <p>Main.java</p> <pre><code>TextColumn&lt;Contract&gt; orgNameColumn = new TextColumn&lt;Contract&gt;() { @Override public String getValue(Contract contract) { return contract.getcontOrgName(); }}; orgNameColumn.setSortable(true); CellTable&lt;Contract&gt; tableContract = new CellTable&lt;Contract&gt;(); tableContract.addColumn(orgNameColumn, "OrgName"); ListDataProvider&lt;Contract&gt; contractDataProvider = new ListDataProvider&lt;Contract&gt;(); contractDataProvider.addDataDisplay(tableContract); GetContractsServiceAsync getContractsService = GWT.create(GetContractsService.class); getContractsService.getContracts(new AsyncCallback&lt;List&lt;Contract&gt;&gt;() { public void onFailure(Throwable caught) { // Show the RPC error message to the user } public void onSuccess(List&lt;Contract&gt; result) { contractDataProvider.getList().clear(); contractDataProvider.getList().addAll(result); ListHandler&lt;Contract&gt; columnSortHandler = new ListHandler&lt;Contract&gt;(result); columnSortHandler.setComparator(orgNameColumn, new Comparator&lt;Contract&gt;() { public int compare(Contract o1, Contract o2) { if (o1 == o2) { return 0; } if (o1 != null) { return (o2 != null) ? o1.getcontOrgName().compareTo(o2.getcontOrgName()) : 1; } return -1; } }); tableContract.addColumnSortHandler(columnSortHandler); table.getColumnSortList().push(orgNameColumn); } }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload