Announcement

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

    Group summary not appearing.

    Hi,
    I am facing some issues in multi group functionality in Smart GWT.
    The first problem is that when we upgraded the Smart GWT version to 4.0 the group summary stopped appearing. After googling I found that this is an issue with the smart GWT code. So I upgraded to the patched version and took the nightly build (2013-12-23). The group summary started appearing. Now there is another issue where the Group summary stops appearing if I use the GroupTitleRenderer.

    This is not specific to any browser.

    Code snapshot:

    direction.setGroupTitleRenderer(groupTitleRenderer);
    product.setGroupTitleRenderer(groupTitleRenderer);

    private GroupTitleRenderer getGroupTitleRenderer() {
    return new GroupTitleRenderer() {
    @Override
    public String getGroupTitle(Object value, GroupNode groupNode, ListGridField listGridField, String fieldName, ListGrid listGrid) {
    return getGroupHeaderTitle(fieldName, value);
    }
    };
    }

    #2
    We're not seeing a problem with a custom groupTitleRenderer impacting the group summary display in the SmartGWT 4.0p.
    We're testing with the latest nightly build, and here's a complete test case demonstrating this scenario:

    Entry point class:
    Code:
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.widgets.grid.GroupNode;
    import com.smartgwt.client.widgets.grid.GroupTitleRenderer;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    import com.smartgwt.sample.client.TestDataSource;
    
    public class GroupTitleSummaryTest implements EntryPoint {
    
    	@Override
    	public void onModuleLoad() {
    		
    		ListGrid testGrid = new ListGrid();
    		testGrid.setWidth(300);
    		testGrid.setHeight(300);
    		
    		testGrid.setDataSource(new TestDataSource());
    		testGrid.setAutoFetchData(true);
    		
    		testGrid.setGroupByField("f2");
    	
    		testGrid.setShowGroupSummary(true);
    		
    		ListGridField f2 = new ListGridField("f2");
    		f2.setGroupTitleRenderer(new GroupTitleRenderer() {
    			
    			@Override
    			public String getGroupTitle(Object groupValue, GroupNode groupNode,
    					ListGridField field, String fieldName, ListGrid grid) {
    				String groupValString = (String)groupValue;
    				// return "# n" rather than "Group n"
    				return "#" + groupValString.substring(5);
    			}
    		});
    		
    		testGrid.setFields(f2);
    		testGrid.setUseAllDataSourceFields(true);
    		
    		testGrid.draw();
    		
    	}
    
    }
    Simple (client-only) test dataSource:
    Code:
    package com.smartgwt.sample.client;
    
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.data.DataSourceField;
    import com.smartgwt.client.types.FieldType;
    import com.smartgwt.client.widgets.grid.ListGridRecord;
    
    public class TestDataSource extends DataSource {
    	public TestDataSource () {
    		setClientOnly(true);
    		
    		DataSourceField pkField = new DataSourceField("pk", FieldType.INTEGER);
    		pkField.setPrimaryKey(true);
    		
    		setFields(
    				pkField, 
    				
    				new DataSourceField("f1", FieldType.TEXT),
    
    				new DataSourceField("f2", FieldType.TEXT),
    
    				new DataSourceField("f3", FieldType.TEXT),
    
    				new DataSourceField("bool", FieldType.BOOLEAN),
    
    				new DataSourceField("date", FieldType.DATETIME)
    		);
    		
    		setCacheData(
    				new ListGridRecord() {{
    					setAttribute("pk", 0);
    					setAttribute("f1", "Record 0");
    					setAttribute("f2", "Group A");
    				}},
    				new ListGridRecord() {{
    					setAttribute("pk", 1);
    					setAttribute("f1", "Record 1");
    					setAttribute("f2", "Group A");
    				}},
    				new ListGridRecord() {{
    					setAttribute("pk", 2);
    					setAttribute("f1", "Record 2");
    					setAttribute("f2", "Group B");
    				}},
    				new ListGridRecord() {{
    					setAttribute("pk", 3);
    					setAttribute("f1", "Record 3");
    					setAttribute("f2", "Group C");
    				}},
    				new ListGridRecord() {{
    					setAttribute("pk", 4);
    					setAttribute("f1", "Record 0");
    					setAttribute("f2", "Group C");
    				}}
    		);
    	}
    }
    If you run this you'll see the custom title renderer is correctly rendering out the group title ("# 1", "# 2", etc), and the group summary row is also showing, displaying totals from the numeric "pk" field.

    There must be something special about your grid which is causing you to see different behavior. We'd recommend you get us a test case so we can see what the problem is. Probably the best approach would be to take the above test case as a starting-point and modify it to more closely resemble what you have in your real use case until it exhibits the problem, so we have a minimal test case we can run on our end.

    Regards
    Isomorphic Software

    Comment

    Working...
    X