title: Resize DataGrid When Shown
body: <p>I'm trying to write my flex application so that it restores the user's settings when it starts up. The application has 3 data grids (only one is visible [on screen] at any time) and I simply save the state of the grids if the user ever does any resize events.</p>
  
  <p>Saving the state works perfectly, the problem comes when restoring. It seems that only the visible data grid gets restored properly. On all the other grids, the widths are all wrong and do not match the settings I restored from.</p>
  
  <p>The problem is that, when the application starts, the data grids are not sized correctly. Each data grid takes up the full screen, but initially they are only given a very small size (ie. 200 width)</p>
  
  <p>Is there some way to force the data grid to resize properly when it is created? Or is it possible to know when the data grid is "maximized" I don't want to hook up to the resize event - if possible - because I would get that quite frequently, and I only want to restore the settings once.</p>
  
  <p>Here's the code I'm using to restore the column widths:</p>
  
  <pre><code>var grid:DataGrid = ...;
  
  ... for each column ...
  ... parse width into width (ie. width is now "320")
  // If it's in the config, it's visible
  col.visible = true;
  col.width = width;
  
  ... After loop ...
  grid.invalidateSize();
  grid.invalidateDisplayList();
  </code></pre>
  
  <hr>
  
  <p>Edit:</p>
  
  <p>Here's the info you guys requested:</p>
  
  <ul>
  <li><p>The settings are saved into a database (the flex proejct is connected to JBoss). I simply save a CSV type thing with the column's name and it's width. I know this works because the one data grid that is visible when the application starts gets sized correctly.</p></li>
  <li><p>Yes, the grids use relative sizes (ie. 100%) -- I can't really change that because I want the grid to take up all available space in its container -- and I want the user to be able to resize their browser and still have it look right.</p></li>
  <li><p>Each grid is contained in its own Hbox</p></li>
  <li><p>The data grids are created when the application starts -- you can only see one of them though. They are in a tab navigator type thing, but it's creation policy is set to "all" so they can be populated with data (the population takes some time, and typically the user sits on the front grid for a little while.)</p></li>
  <li><p>I can't put my resize stuff in the creationComplete handler because I end up with the same problem. The grid's size is like 50 right after it's created (it should be like 1000, 100% of the page width) -- and then I go to set the sizes of the columns (which are obviously > 50) and the resize does nothing</p></li>
  </ul>