weralio

dijit.byId("grid") - TypeError: grid is undefined or grid.setStore is not a function

Discussion created by weralio on Jan 25, 2013
Latest reply on Oct 7, 2016 by Dave.J
Getting the error trying to set a datagrid.  grid is defined as:

<table data-dojo-type="dojox.grid.DataGrid" data-dojo-id="grid" id="grid" data-dojo-props="rowsPerPage:'5', rowSelector:'20px'">
      <thead>
        <tr>
           <th field="BUS_FID">ID</th>
   <th field="L_F_ADD">From</th>
   <th field="R_T_ADD">To</th>
   <th field="PREFIX">Prefix</th>
   <th field="PRETYPE">Pretype</th>
   <th field="NAME">Name</th>
   <th field="POSTAL_L">Zip</th>
   <th field="STATE00_L">State</th>
   <th field="COUNTY00_L">County</th>
   <th field="MCD00_L">MCD</th>
   <th field="PLACE00_L">Place</th>
        </tr>
      </thead>
</table>


both:  dojo.require("dojox/grid/DataGrid");
        dojo.require("dojo/data/ItemFileReadStore");

(btw: like in the example http://help.arcgis.com/en/webapi/javascript/arcgis/jssamples/#sample/find_map_datagrid  .. error occurs on trying to access grid since dijit.byId('grid') is undefined)

       //Create data store and bind to grid.
        store = new dojo.data.ItemFileReadStore({ data:data });
        var grid = dijit.byId('grid');
        grid.setStore(store);

PS:  store and data have the right values

I managed to get the structure with: dijit.byId(document.getElementById("grid") but then the grid.setStore(store) function gives me grid.setStore is not a function

Outcomes