I am adapting the Showcase adaptive filter example and query my data via GWT-RPC instead. If I enable paging via startRow and endRow, the filtering on my listgrid no longer works. No matter what I type in the filter box, it just reloads the unfiltered records. If I disable paging and just download the whole data all in one swoop, the filtering is working. How do I make filtering work with server-side paging?
Thanks,
Khoa
Code fragments:
Thanks,
Khoa
Code fragments:
Code:
/* Client side */ public void onModuleLoad() { DataSource dataSource = AlertDS.getInstance(); ListGridField subsId = new ListGridField("subscriberId", "Subscriber"); ListGridField actionTag = new ListGridField("actionTag", "Action Tag"); final ListGrid alertGrid = new ListGrid(); alertGrid.setWidth(400); alertGrid.setHeight(300); alertGrid.setShowFilterEditor(true); alertGrid.setFilterOnKeypress(true); alertGrid.setAlternateRecordStyles(true); alertGrid.setShowAllRecords(false); alertGrid.setAutoFetchData(true); alertGrid.setAutoFetchAsFilter(true); alertGrid.setDataSource(dataSource); alertGrid.setFields(subsId, actionTag); alertGrid.draw(); } /* Datasource */ public class AlertDS extends GwtRpcDataSource { private static AlertDS instance = null; private static RoamMonitorServiceAsync service; public static DataSource getInstance() { if (instance == null) { instance = new AlertDS("alertDS"); } return instance; } private AlertDS(String id) { setID(id); DataSourceTextField subsId = new DataSourceTextField("subscriberId", "Subscriber", 128, true); DataSourceTextField actionTag = new DataSourceTextField("actionTag", "Action Tag", 100, true); setFields(subsId, actionTag); service = GWT.create(RoamMonitorService.class); } @Override protected void executeFetch(final String requestId, DSRequest request, final DSResponse response) { // Paging, sorting support int startRow = request.getStartRow().intValue(); int endRow = request.getEndRow().intValue(); String sortedBy = request.getSortedBy(); service.getAlerts("3014441700", startRow, endRow, sortedBy, new AsyncCallback<ArrayList<Alert>> () { @Override public void onFailure(Throwable caught) { response.setStatus (RPCResponse.STATUS_FAILURE); processResponse (requestId, response); } /* Server side -- service implementation */ @Override public ArrayList<Alert> getAlerts(String subscriber, int startRow, int endRow, String sortedBy) { // For testing purpose: generate (endRow-startRow+1) dummy alerts return generateDummyAlerts(subscriber, startRow, endRow); }
Comment