Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    ListGrid + Adaptive Filter + Paging

    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:
    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);
    	}

    #2
    Hello Khoa,

    Did any one get back to you on this? I am having the same issue.

    Thanks,

    Comment


      #3
      This is a really ancient thread, but we've noticed it comes up for some Google searches, so we thought we'd add a reply:

      You can use a dataProtocol:clientCustom DataSource to connect to GWT-RPC or indeed any kind of system that can return data, whether it goes over a network or not. SmartGWT doesn't assume anything about how you are retrieving the data. You simply get a DSRequest object, and you are required to produce a DSResponse object.

      While GWT-RPC is basically obsolete, there is a thread here about how to connect a DataSource to GWT-RPC via this mechanism:

      https://forums.smartclient.com/forum...implementation

      Comment

      Working...
      X