title: Dojo DataGrid, programmatic creation
body: <p>I'm trying to create a DataGrid dynamically. Declarative creation is working fine:</p>
  
  <p>A source of data:</p>
  
  <pre><code>&lt;span dojoType="dojo.data.ItemFileReadStore" 
      jsId="theStore" url="dataonly001.json"&gt;
    &lt;/span&gt;
  </code></pre>
  
  <p>a simple layout:</p>
  
  <pre><code>&lt;script type="text/javascript" &gt;    
    var layout = [ {
              field: 'custId',
              name: 'Id',                   
          } // more items elided ...
       ]; 
  &lt;/script&gt;
  </code></pre>
  
  <p>The grid:</p>
  
  <pre><code>&lt;body class="tundra" id="mainbody"&gt; 
     &lt;div id="grid"
       dojoType="dojox.grid.DataGrid"
       store="theStore"
       structure="layout"  
       autoWidth="true"     
   &gt;&lt;/div&gt;   
  &lt;/body&gt;
  </code></pre>
  
  <p>And I get the grid displayed nicely. Instead, I want to create the grid dynamically. For the sake of figuring out what's broken I've tried to use exactly the same layout and store, removing just the grid declaration and adding this script:</p>
  
  <pre><code>  &lt;script type="text/javascript" djConfig="parseOnLoad: true, debugAtAllCosts: true"&gt;
  
    dojo.addOnLoad(function(){
          // initialise and lay out home page
          console.log("Have a store:" + theStore);
          console.log("Have a structure:" + layout);
  
          var grid = new dojox.grid.DataGrid({
                  id : "grid",
                  store : theStore,
                  clientSort : "true",
                  structure : layout
          });
          grid.startup();
  
      dojo.place(grid.domNode, dojo.body(), "first");                     
    });
  
   &lt;/script&gt;
  </code></pre>
  
  <p>The effect that I get is a completely empty rectangle is displayed. Using FireBug I can see that the DataGrid widget is created but that it has no rows or columns. So my guess is that the datastore or layout are not being passed correctly. However, it does appear that at the point of creation the values of <code>theStore</code> and <code>layout</code> are correct.</p>
  
  <p>Suggestions please, or indeed a working example of a programmatic grid might solve the problem.</p>