Results 1 to 2 of 2

Thread: row layout with horizontal orientation makes it impossible to compute height

  1. #1
    Sencha User
    Join Date
    Apr 2011
    Posts
    28

    Default row layout with horizontal orientation makes it impossible to compute height

    Hi,

    suppose you have got a layout container with vertical layout. In it, you create a layout container with Orientation.HORIZONTAL.

    Code:
    public class UploadFileWidget{
    public UploadFileWidget() {
        setLayout( new RowLayout( Orientation.VERTICAL ) );
        setMonitorWindowResize( true );
        createWidgets();
      }
    
    private void createWidgets() {
        addUploadArea();
      }
    
      private void addUploadArea() {
        uploadArea = new UploadArea();
        add( uploadArea, new RowData( 1, -1 ) );
      }
    
    }
    
    private class UploadArea extends LayoutContainer {
        
        private static final int UPLOAD_HEADER_HEIGHT = 26;
        private UploadFileCell uploadCell;
        private LayoutContainer nameLabelContainer;
        private Label nameLabel;
        
        public UploadArea() {
          this.setLayout( new RowLayout( Orientation.HORIZONTAL ) );
          createWidgets();
          setHeight( UPLOAD_HEADER_HEIGHT );
        }
        
        public void setNameText( String nameText ) {
          nameLabel.setText( nameText );
        }
        
        public void createWidgets() {
          addNameArea();
          addUploadcellArea();
        }
    
        private void addUploadcellArea() {
          uploadCell = new UploadFileCell();
          add( uploadCell, new RowData( 0.5, 1 ) );
        }
    
        private void addNameArea() {
          nameLabelContainer = new LayoutContainer();
          nameLabel = new Label();
          nameLabelContainer.add( nameLabel );
          add( nameLabelContainer, new RowData( 0.5, 1 ) );
        }
        
      }
    now, if I add that container to my application, the uploadArea is not shown, because it does not have a height.
    I have tried several combinations of autoHeight set to true, adding the components with different height parameters (1 instead of -1 in RowData).
    I also tried to set the container's height to that of the maximum of the containing elements by overriding the afterRender method. Unfortunately latter throws an exception because getHeight on a component may only be called after it is rendered.
    The only way to make the container visible is to set the height to a fixed height (see code).

    So does anybody has an idea how to compute and set the height according to a container's children in this case?

    Thanks a lot

  2. #2
    Sencha User
    Join Date
    Apr 2011
    Posts
    28

    Default

    I used RowLayout in many of my gui screens. In general, choosing the right height parameters was always not easy. With Orientation.HORIZONTAL this is even worse.

    So for now I try to avoid using RowLayout with Orientation.HORIZONTAL and use ColumnLayout where appropriate. Although ColumnData does not have the possibility to set Margins and I have to do margins with css.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •