Announcement

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

    setShowGridSummary(true) after grid is drawn breaks grid with filter header

    Hi,

    I'm using SmartGWT nightly build (2011-07-30) on Chrome 12.0.742.124 and Firefox 5.0 on Ubuntu 10.04 64bit.

    I have a requirement where a table with filter headers may or may not have a summary row (or it can have 3) and as such setShowGridSummary is set dynamically after the component is drawn. This, however, breaks the listgrid headers by seemingly shifting the whole main table up by around 20 pixels.

    In the following example I do this just before I fetch data for the table:

    Code:
    import java.util.ArrayList;
    import java.util.List;
    
    import com.smartgwt.client.data.DSRequest;
    import com.smartgwt.client.data.DSResponse;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.data.DataSourceField;
    import com.smartgwt.client.data.OperationBinding;
    import com.smartgwt.client.types.AutoFitWidthApproach;
    import com.smartgwt.client.types.DSOperationType;
    import com.smartgwt.client.types.DSProtocol;
    import com.smartgwt.client.types.FieldType;
    import com.smartgwt.client.types.ListGridFieldType;
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    import com.smartgwt.client.widgets.grid.ListGridRecord;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    
    public class FilterAndSummaryGrid extends VLayout {
    	
    	private final ListGrid table;
    	public FilterAndSummaryGrid(){
    		super(5);
    		setWidth("50%");
    		setHeight("50%");
    		
    		IButton fetchButton = new IButton("Fetch Data", new ClickHandler() {
    			public void onClick(ClickEvent event) {
    				handleFetch();
    			}
    		});
    		addMember(fetchButton);
    		
    		table = new ListGrid();
    		table.setAlternateRecordStyles(true);
    		table.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH);
    		table.setHeaderHeight(40);
    		table.setShowGridSummary(false);
    		table.setShowFilterEditor(true);
    		table.setDataSource(new TableDataSource());
    		
    		ListGridField[] fields = new ListGridField[10];
    		for(int i=0;i<10;i++){
    			fields[i] = new ListGridField("Field"+i);
    			fields[i].setType(ListGridFieldType.FLOAT);
    		}
    		table.setFields(fields);
    		
    		addMember(table);
    	}
    	
    	private void handleFetch() {
    		table.setData(new ListGridRecord[0]);
    		table.setShowGridSummary(true);
    		table.fetchData(table.getFilterEditorCriteria());
    	}
    	
    	private static class TableDataSource extends DataSource {
    		
    		private TableDataSource(){
    			setID("TableDatasource1");
    			setClientOnly(true);
    			setupOperationBindings();
    			setPrimaryKey();
    		}
    		
    		private void setPrimaryKey() {
    			DataSourceField keyField = new DataSourceField("IdNum", FieldType.BINARY);
    			keyField.setPrimaryKey(true);
    			keyField.setHidden(true);
    			addField(keyField);
    		}
    		
    		private void setupOperationBindings() {
    			OperationBinding fetch = new OperationBinding(DSOperationType.FETCH, "");
    			fetch.setDataProtocol(DSProtocol.CLIENTCUSTOM);
    			
    			OperationBinding add = new OperationBinding(DSOperationType.ADD, "");
    			add.setDataProtocol(DSProtocol.CLIENTCUSTOM);
    			
    			OperationBinding update = new OperationBinding(DSOperationType.UPDATE, "");
    			update.setDataProtocol(DSProtocol.CLIENTCUSTOM);
    			
    			OperationBinding remove = new OperationBinding(DSOperationType.REMOVE, "");
    			remove.setDataProtocol(DSProtocol.CLIENTCUSTOM);
    			
    			setOperationBindings(fetch, add, update, remove);			
    		}	
    		
    		protected Object transformRequest(DSRequest request) {
    			if (request.getOperationType() == DSOperationType.FETCH)
    				handleFetch(request);
    			
    			return super.transformRequest(request);
    		}
    
    		private void handleFetch(DSRequest request) {
    			List<ListGridRecord> records = new ArrayList<ListGridRecord>();
    			for(int i=0;i<5000;i++){
    				ListGridRecord record = new ListGridRecord();
    				for(int j=0;j<10;j++){
    					record.setAttribute("Field"+j, Math.random());
    				}
    				records.add(record);
    			}
    			
    			
    			DSResponse response = new DSResponse();
    			response.setData(records.toArray(new ListGridRecord[0]));
    			processResponse(request.getRequestId(), response);
    		}
    	}
    }
    Code:
    public void onModuleLoad() {
        new FilterAndSummaryGrid().draw();
    }

    #2
    I've actually taken the standalone case down to a few lines:

    Code:
    public void onModuleLoad() {
    	ListGrid grid = new ListGrid();
    	grid.setWidth("50%");
    	grid.setHeight("50%");
    	//This is just to show that the headers are actually there
    	grid.setHeaderHeight(40);
    	grid.setShowGridSummary(true);
    	grid.setShowFilterEditor(true);
    	grid.setFields(new ListGridField[]{new ListGridField("Field1"), new ListGridField("Field2"), 
    			new ListGridField("Field3"), new ListGridField("Field4")});
    	grid.draw();
    }
    As you can see, the whole 'main' table is shifted up by about 20 pixels (the height of a row). As a consequence the top row in the grid (when filled with data) does not fire a SelectionEvent.

    Comment


      #3
      I also found the same problem and I had to reverse up to SmartGWT LGPL nightly build (2011-07-23), in my project all ListGrid with the following settings

      grid.setShowGridSummary(true);
      grid.setShowGroupSummary(true);
      grid.setShowFilterEditor(true);

      they do not have the column headers displayed and the whole 'main' table is shifted up by about 20 pixels.

      up to SmartGWT LGPL nightly build (2011-07-23) it works fine, subsequent versions don't works and display the behavior described.

      OS Windows Xp, Windows 7
      FF 4.0, FF 5.0, Crome 12.0.742.122.

      Thanks for any help

      Comment


        #4
        ... experiencing same issue.
        SmartGWT 2.5 final release (8/02)

        Comment


          #5
          hey guys,
          got the same issue on Smartclient 8.1 LGPL (official release 8/2).
          Apparently seems that filtereditor and gridsummaries can't stay together. If so, the first row of the grid has no click handler (as it would be an header part and not a row itself).
          Any suggestion about how to solve?

          Comment


            #6
            We've verified this bug and fixed.
            We'll post a new nightly build containing the fix tonight / tomorrow morning. The build will be dated Aug 10th 2011 and will be available at http://www.smartclient.com/builds/ under the 2.x (SGWT) or 8.1 (SC) directory.

            This build will be cut from the release branch and will differ from the official release build only in that it contains this and a couple of other bug-fixes (no new features or major changes).

            Comment

            Working...
            X