Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Sencha Premium Member
    Join Date
    Jun 2010
    Posts
    35
    Vote Rating
    0
    eguardiola is on a distinguished road

      0  

    Default Height of row is wrong when using a custom Cell

    Height of row is wrong when using a custom Cell


    Only when using a custom Cell and the string to render is empty.


    Code:
    package es.inaer.taller.client;
    
    import java.util.ArrayList;
    
    import com.google.gwt.cell.client.TextCell;
    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.user.client.ui.RootPanel;
    import com.sencha.gxt.core.client.ValueProvider;
    import com.sencha.gxt.data.shared.ListStore;
    import com.sencha.gxt.data.shared.ModelKeyProvider;
    import com.sencha.gxt.widget.core.client.button.TextButton;
    import com.sencha.gxt.widget.core.client.container.FlowLayoutContainer;
    import com.sencha.gxt.widget.core.client.event.SelectEvent;
    import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
    import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
    import com.sencha.gxt.widget.core.client.grid.ColumnModel;
    import com.sencha.gxt.widget.core.client.grid.Grid;
    
     
    public class Test implements EntryPoint {
    	
    	private int newId = -1;
    
    	public class Cat  {
    		private String id;
    		private String name;
    		
    		public Cat(String id, String name) {
    			this.id = id;
    			this.name = name;
    		}
    
    		public String getId() {
    			return id;
    		}
    		public void setId(String id) {
    			this.id = id;
    		}
    		public String getName() {
    			return name;
    		}
    		public void setName(String name) {
    			this.name = name;
    		}
    	}
    	
    	public void onModuleLoad() {
    		
    		ArrayList<ColumnConfig<Cat, ?>> colConfigs = new ArrayList<ColumnConfig<Cat, ?>>();
    
    		ColumnConfig<Cat, String> nameCol = new ColumnConfig<Cat, String>(new ValueProvider<Cat, String>(){
    
    			@Override
    			public String getValue(Cat object) {
    				return object.getName();
    			}
    
    			@Override
    			public void setValue(Cat object, String value) {
    				object.setName(value);
    			}
    
    			@Override
    			public String getPath() {
    				return "name";
    			}}, 100, "Name");
    		
    		// Height of a new row on Grid is wrong when adding a new element without text if a custom Cell is configured.
    		// Commenting this line height of the new row is right 
    		nameCol.setCell(new TextCell());
    		
    		colConfigs.add(nameCol);
    		
    		ColumnModel<Cat> columModel = new ColumnModel<Cat>(colConfigs);
    		
    		final ListStore<Cat> catStore = new ListStore<Cat>(new ModelKeyProvider<Cat>() {
    
    			@Override
    			public String getKey(Cat item) {
    				return item.getId();
    			}}); 
    		
    		final Grid<Cat> grid = new Grid<Cat>(catStore, columModel);
    		grid.getView().setForceFit(true);
    		grid.setWidth(300);
    		grid.setHeight(400);
    		grid.setBorders(true);
    		
    		TextButton b = new TextButton("Add");
    		b.addSelectHandler(new SelectHandler() {
    			
    			@Override
    			public void onSelect(SelectEvent event) {
    				catStore.add(new Cat("" + newId--, ""));
    				
    			}
    		});
    		
    		FlowLayoutContainer flc = new FlowLayoutContainer();
    		flc.add(grid);
    		flc.add(b);
    		
    		RootPanel.get().add(flc);
    	}
    
    }
    gridtest.jpg

  2. #2
    Sencha User WesleyMoy's Avatar
    Join Date
    Oct 2009
    Location
    Redwood City, California
    Posts
    402
    Vote Rating
    2
    WesleyMoy is on a distinguished road

      0  

    Default


    This is the expected behaviour. An empty string has no height. If you really want to render a blank cell but maintain text height, you can consider rendering a &nbsp;.

Thread Participants: 1