Announcement

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

    9000 records are not too many - SelectItem with optionDataSource

    Hello all,

    I have a question due to I need load more than 9000 records in a SelectItem and I see it is very slow.

    I am using RPC and the SmartGWT version is LGPL 2.4. In the client we use Internet Explorer but I have tested Firefox and it is slow as IE.

    I do this:

    DataSource:
    Code:
    DataSource dsTowns = new DataSource();
    
    DataSourceIntegerField idtown = new DataSourceIntegerField("id","Id:");
    idtown.setPrimaryKey(true);
    
    DataSourceTextField nametown = new DataSourceTextField("name","Name:");
    
    dsTowns.setFields(idtown,nametown);
    
    dsTowns.setClientOnly(true);
    SelectItem:
    Code:
    siTowns.setOptionDataSource(dsTown.getInstance());
    siTowns.setDisplayField("name");
    siTowns.setValueField("id");
    RPC call
    Code:
    TownRPCAsync townService = GWT.create(TownRPC.class);
    townService.findAllTowns(new AsyncCallback<Town[]>{
    	@Override
    	public void onSuccess(Town[] data){
    
    		DataClass[] records = new DataClass[data.length];
    
    		for (int i=0; i<data.length; i++){
    			records[i] = new DataClass();
    			records[i].setAttribute("id", data[i].getId());
    			records[i].setAttribute("name", data[i].getName());
    		}
    
    	    	this.setTestData(records);
    	}
    }
    I use Town[] because I have tested List<Town> and is a bit more slow. And I use DataClass and setTestData() because I have realized it is a bit more fast than to create a ListGridRecord for each town.

    And yet it is very slow.

    My question is:

    Is there some property or some other system (json , xml or other) that is faster? Or at least, do not block the browser while loading data.


    Thanks for all in advance
    Last edited by SrArcos; 11 May 2011, 04:18.

    #2
    Generally speaking, it is not a good idea to load that many items into a user interface. The user cannot easily navigate 9,000 records, especially in a drop-down listbox (SelectItem). You might consider using a filter to limit the number of results that are returned.

    If you really need to display all of the items, another option is to not use a picklist at all but a list grid that supports paging.

    Lastly, if you feel that you absolutely must display all 9,000 items at once, then you really can't complain about performance. What's causing the browser to block isn't the call to the server but the memory processing that is required to load those 9,000+ items into the DOM. This is a side-effect of using Javascript and not something that the SmartClient/SmartGWT toolkit is doing.

    You really should re-evaluate the need to handle all of that data at once, tho. Also, if possible, I would suggest using a general id/name value object from your finder query rather than deriving a new array from the Town array which presumably contains the entire Town data structure.

    Comment


      #3
      All good points, but actually the quick answer is that the PickList does indeed support paging and he just needs to start using startRow and endRow to limit the results. Then it scales pretty much indefinitely (tens of millions not a problem).

      Also, we don't recommend GWT-RPC (see FAQ), performance can be one reason but isn't the primary reason.

      Comment


        #4
        Hi Isomorphic,

        I have the same pbm and the customer suffers from this pbm please explain more the solution :<<
        , I would suggest using a general id/name value object from your finder query rather than deriving a new array from the Town array which presumably contains the entire Town data structure>>

        Comment

        Working...
        X