Announcement

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

    ListGrid's groupBy Fails When There Are Too Many Records (Probable Bug)

    Hi Support Team,

    I found a probable bug in Smart GWT 3.1 LGPL edition. My SmartClient version is v8.3p_2012-11-27/LGPL Development Only (built 2012-11-27). I tested it by using Firefox 16.0.2. My Firefox's GWT plugin version is 1.0.11336. I use Windows 7 x64.

    The bug is that listgrid's groupBy functionality fails if there are too many records inside the listgrid. The failure is silent, means that there is no error warning (neither in browser nor in Eclipse). The list grid is successfully populated with data, though.

    Here is the code

    Code:
    package com.rapidesuite.example.client;
    
    
    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.user.client.Random;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.data.DataSourceField;
    import com.smartgwt.client.data.Record;
    import com.smartgwt.client.types.FieldType;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    
    public class TestSmartGwt implements EntryPoint
    {
    	//[b]CHANGE THE VALUE OF THIS VARIABLE (TRY 100 AND 1000). 100 should be okay, but 1000 should cause problem[/b]
    	private final int NUMBER_OF_RECORDS = 1000;
    	
    	public void onModuleLoad()
    	{
    		SC.showConsole();
    		
    		//long string array, to be used for grouping
    		final String longStringsArray[] = {
    				"ijwefehfuisadosauihnfijasd78asuhdiuashgduyashdnfiuahuhnsdaiuaSHduasN",
    				"bdjknqowiduwefjaweuidsdakjbywetdfygwehbytwefdy3r6rtgsduhbfgsdhvjhbdsajbj",
    				"nwsdcijksmakidfuhwe76rtgewiuajdnuygwehjknuygweiujqwehnuywebfjkwewun",
    				"oidwejhdimniwuqehdiowemnjduiwehrdiojmwenudfyhwnkdjhqw378edhn3h8u",
    				"ierhfiwekmiowejhfdoiwemdioewuhduiom23iuejoiwemeoifuyhwq",
    				"uioewajdowekdewiojdkoiwejfoiewimfiewufdnmheiwrjfnuy23geu32y4rfbuyefuwejhnfuj",
    				"jkdnfk34urhjwdiscolajs8dciodijwqiuedfnowieifjierufjoiewrfj9wierfjiweufdkmfnuwaidnfiujhnwei",
    				"iusdjfowj8iewanmeiodfuhsanicjmoeidjwoiaeiaudnoiwejd9owq3i4krt34miuervjnoiergm9ie",
    				"GHUHN*Uhbaiuwdsnuwqexciuwehdcoiwefjcedfmcvoivm,er98e7rfnlknasdUyhjewfnanm",
    				"98237rdj cmisaudhjoiOIJMIKUGH^&TYVbesalfijwae9uifsdlMSADoifvhjm",
    				"uiowefjiosdkl,mwoadjwqiohwqeuidmsaoidqwendoEHUYEIFNMOIWERYFHWAEIUNFI",
    				"IUWEHNFDIOWKEIHDQWUNOIASDHIUQWMDOIWEFHJOWEALDJKIWUEHUI43GHIUyugiuewghroiwehrwqeuinik",
    				"erhnfiweqomrfowidcuhuimawosidyhqweiodmkweiucnskldjfwienmdfowiesahdioweudfhiuernfgoasuidhin",
    				"oiuwejnmdfklsamasihdgniqwlk3ejh2q38w7dghbcdszklmcis8hwdpoqfj9igm ujednQUIFGBWEIFUSB",
    				"OUI3NREMKL23MDC98SYHOIjmnuibnoijhwefkwe9ifuhaoifughweriuuehfdiuweafgbhfwei9uhnj"
    		};
    		
    		
    		//greeting array, to be also used for grouping
    		final String greetingsArray[] = {"Good Morning", "Good Afternoon", "Good Evening", "Good Night", "Good Lord ..."};
    		
    		
    		//constants for column identification
    		final String ID = "id";
    		final String LONG_STRING = "longString";
    		final String HELLO = "hello";
    		final String GREETING = "greeting";
    		
    		//smartgwt plumbing, never mind about this
    		DataSource ds = new DataSource();
    		ds.setClientOnly(true);
    		DataSourceField idField = new DataSourceField(ID, FieldType.INTEGER);
    		idField.setPrimaryKey(true);
    		ds.addField(idField);
    		ds.addField(new DataSourceField(LONG_STRING, FieldType.TEXT));
    		ds.addField(new DataSourceField(HELLO, FieldType.TEXT));
    		ds.addField(new DataSourceField(GREETING, FieldType.TEXT));
    		
    		//populating data into data source
    		for (int i = 0 ; i < NUMBER_OF_RECORDS ; i++) {
    			Record record = new Record();
    			record.setAttribute(ID, new Integer(i));
    			
    			for (int j = longStringsArray.length ; j > 0 ; j--) {
    				if ((i+1)%j == 0) {
    					record.setAttribute(LONG_STRING, longStringsArray[j-1]);
    					break;
    				}
    			}
    			
    			int rand = Random.nextInt(greetingsArray.length);
    			String greeting = greetingsArray[rand];
    			
    			
    			
    			record.setAttribute(HELLO, "Hello World "+i+", "+greeting);
    			record.setAttribute(GREETING, greeting);
    			
    			
    			ds.addData(record);
    		}
    		
    		//another smartgwt plumbing
    		ListGrid listGrid = new ListGrid(ds);
    		listGrid.setFields(new ListGridField(ID, "ID"),
    				new ListGridField(LONG_STRING, "Long String"),
    				new ListGridField(HELLO, "Hello"),
    				new ListGridField(GREETING, "Greeting")
    				);
    		listGrid.setWidth100();
    		listGrid.setHeight100();
    		listGrid.fetchData();
    		
    		//here is the (probably) FAILING groupBy
    		listGrid.groupBy(LONG_STRING, GREETING);
    		
    		//just hide fields which are (supposed to be) displayed in the grouping
    		listGrid.hideFields(LONG_STRING, GREETING);
    		
    		//another smartgwt plumbing
    		listGrid.draw();
    		listGrid.show();
    	}
    }
    FYI, there is nothing suspicious in the server and client side logs, though. But, anyway, here they are:
    Server side:
    Code:
    Initializing App Engine server
    Nov 29, 2012 7:33:41 AM com.google.apphosting.utils.jetty.JettyLogger info
    INFO: Logging to JettyLogger(null) via com.google.apphosting.utils.jetty.JettyLogger
    Nov 29, 2012 7:33:41 AM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml
    INFO: Successfully processed C:\Users\User\workspace\TestSmartGwt\war\WEB-INF/appengine-web.xml
    Nov 29, 2012 7:33:41 AM com.google.apphosting.utils.config.AbstractConfigXmlReader readConfigXml
    INFO: Successfully processed C:\Users\User\workspace\TestSmartGwt\war\WEB-INF/web.xml
    Nov 29, 2012 3:33:42 PM com.google.appengine.tools.development.DevAppServerImpl start
    INFO: The server is running at http://localhost:8888/
    Nov 29, 2012 3:33:42 PM com.google.appengine.tools.development.DevAppServerImpl start
    INFO: The admin console is running at http://localhost:8888/_ah/admin
    Nov 29, 2012 3:34:12 PM com.google.appengine.tools.development.LocalResourceFileServlet doGet
    WARNING: No file found for: /testsmartgwt/sc/IDACall
    Client side:
    Code:
    15:33:48.828:INFO:Log:initialized
    15:33:49.882:WARN:Log:New Class ID: 'DataView' collides with ID of existing object with value 'function DataView() {
        [native code]
    }'.  Existing object will be replaced.
    This conflict would be avoided by disabling ISC Simple Names mode.  See documentation for further information.
    15:34:01.322:INFO:Log:isc.Page is loaded

    #2
    This is by design. Take a look at the docs to ListGrid.setGroupByMaxRecords().
    MichalG

    Comment


      #3
      Originally posted by michalg View Post
      This is by design. Take a look at the docs to ListGrid.setGroupByMaxRecords().
      MichalG
      Thanks. Yes, it works once I set it higher.

      On a side note, the documentation says the following:
      Code:
      setGroupByMaxRecords
      
      public void setGroupByMaxRecords(int groupByMaxRecords)
      Maximum number of records to which a groupBy can be applied. If there are more records, grouping will not be available via the default header context menu, and calls to ListGrid.groupBy will be ignored.
      The maximum exists because ListGrid grouping is performed in-browser, hence requires loading of all records that match the current filter criteria before records can be grouped. The default maximum represents a number of records which are safe to load in legacy browsers such as Internet Explorer 8 (modern browsers can handle far more), and is also a good upper limit from the perspective of loading data from a database.
      
      Going beyond this limit can cause "script running slowly" errors from legacy browsers (as well as high database load). To build an interface for grouping that handles arbitrary data volume, use a TreeGrid with loadDataOnDemand with server-side grouping code.
      
      Parameters:
      groupByMaxRecords - groupByMaxRecords Default value is 1000
      See Also:
      groupBy(java.lang.String...)
      I expect that without setting, listgrid of 1000 records will be groupedby without problem and listgrid of 1001 records will not. However, what I found is that my listrid of 1000 records was not grouped, but my listgrid of 999 records was grouped well

      Comment


        #4
        Ah - you're correct - we had an off-by-one logic bug in the framework for this.
        We've now corrected this. Please try the next nightly build - 3.1p or 4.0d branches.

        Regards
        Isomorphic Software

        Comment


          #5
          Originally posted by Isomorphic View Post
          Ah - you're correct - we had an off-by-one logic bug in the framework for this.
          We've now corrected this. Please try the next nightly build - 3.1p or 4.0d branches.

          Regards
          Isomorphic Software
          Thank you :D

          Comment

          Working...
          X