1. #11
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,734
    Vote Rating
    90
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    Try to look at this from the other perspective - it isn't that it breaks the first time and works the other times, it is that it is broken, but happens to look like it is correct the other times.

    There is a good reason for this - the entire point of the layout is to compensate for what html and css are missing, which includes pieces like knowing when it is 'safe' to measure the current size. When you refresh the items or resize, then of course it is safe, but the first time it is not safe, because nothing ever told the grid about its size (forceLayout() is one of the things that causes a parent to tell its children again about sizing).

  2. #12
    Sencha - GXT Dev Team
    Join Date
    Jan 2012
    Location
    Arlington, WA
    Posts
    501
    Vote Rating
    15
    branflake2267 will become famous soon enough

      0  

    Default


    May I suggest trying a configuration something like this. Instead of extending a panel, try out IsWidget.

    Code:
    public class TestIssuePanel implements IsWidget {
    
    
      private UserProperties userProperties = GWT.create(UserProperties.class);
      private ListStore<User> store;
      private Grid<User> grid;
    
    
      private Grid<User> buildGrid() {
        List<ColumnConfig<User, ?>> columnList = new ArrayList<ColumnConfig<User, ?>>();
    
    
        ColumnConfig<User, String> userNameColumn = new ColumnConfig<User, String>(userProperties.username(), 120,
            "User Name");
        columnList.add(userNameColumn);
        columnList.add(new ColumnConfig<User, String>(userProperties.firstName(), 120, "First Name"));
        columnList.add(new ColumnConfig<User, String>(userProperties.lastName(), 120, "Last Name"));
        columnList.add(new ColumnConfig<User, String>(userProperties.emailAddress(), 120, "Email"));
    
    
        ColumnModel<User> columnModel = new ColumnModel<User>(columnList);
        store = new ListStore<User>(userProperties.key());
    
    
        grid = new Grid<User>(store, columnModel);
        grid.setBorders(true);
        grid.getView().setAutoExpandColumn(userNameColumn);
        grid.getView().setForceFit(true);
        grid.getView().setColumnLines(true);
        grid.getView().setAutoExpandMax(2000);
        // or if parent container isn't giving this widget a size, a size can be set. 
        // grid.setPixelSize(300, 200);
    
    
        return grid;
      }
    
    
      private void retrieveUsers() {
        final List<User> users = new ArrayList<User>();
        final User user = new User();
        user.setUsername("username@runnx.commmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm");
        user.setFirstName("First");
        user.setLastName("Brown");
        users.add(user);
    
    
        store.clear();
        store.addAll(users);
      }
    
    
      @Override
      public Widget asWidget() {
        grid = buildGrid();
        VerticalLayoutContainer verticalLayoutContainer = new VerticalLayoutContainer();
        verticalLayoutContainer.add(grid, new VerticalLayoutContainer.VerticalLayoutData(1, -1));
        retrieveUsers();
        return verticalLayoutContainer;
      }
    }
    Code:
      @Override
      public void onModuleLoad() {
        Viewport viewport = new Viewport();
        RootPanel.get().add(viewport);
        
        TestIssuePanel test = new TestIssuePanel();
        viewport.add(test);
      }

Thread Participants: 2

Tags for this Thread