title: dgrid (onDemandGrid) loads on first time button click, but error on second time button is clicked
body: <p>Thanks to some previous help here, I got the Dojo dgrid to work; and even figured out how to tie it to data from my rest service. </p>
  
  <p>Now I added an input box, a button, and all the logic happens on the button-click.  But the second time I click the button, even with the same input value in the input field, I get an error. </p>
  
  <p>ERROR: </p>
  
  <p>TypeError: Cannot read property 'element' of undefined   in StoreMixin.js:33</p>
  
  <p>Including the picture so you can see my console.logs 
  <a href="https://i.stack.imgur.com/fJvTw.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fJvTw.jpg" alt="enter image description here"></a></p>
  
  <p>I read this <a href="https://stackoverflow.com/questions/17922363/how-to-reset-the-ondemandgrid">How To reset the OnDemandGrid</a>, but is it necessary to check to see if grid exists and do different logic? Can't I just "new up" a new one each time? </p>
  
  <p>CODE: </p>
  
  <pre><code>&lt;div data-dojo-type="dijit/layout/ContentPane" data-dojo-props='title:"CustomersGrid"'&gt;
      &lt;label for="lastnameStartsWith"&gt;Lastname Starts With:&lt;/label&gt;
      &lt;input id="lastnameStartsWith" type="text" name="lastnameStartsWith" value="Wag" 
             data-dojo-type="dijit/form/TextBox"
             data-dojo-props="trim:true, propercase:true" /&gt;
      &lt;br /&gt;
      &lt;br /&gt;  
          &lt;button id="queryStudentsButton" data-dojo-type="dijit/form/Button"
          data-dojo-type="dijit/form/Button" 
          data-dojo-props="iconClass:'dijitIconTask'"&gt;
              &lt;span&gt;Query&lt;/span&gt;
              &lt;script type='dojo/on' data-dojo-event='click'&gt;
      require([
          'dstore/RequestMemory',
          'dstore/Memory',
          'dgrid/OnDemandGrid'
      ], function (RequestMemory, Memory, OnDemandGrid) {
                      var url = '../students/' + dojo.byId('lastnameStartsWith').value; 
                      console.log("query students for dataGrid latsnameStartsWith:" + dojo.byId('lastnameStartsWith').value);             
  
                      require(['dojo/request'], function(request){
                          request.get(url,
                               {headers: {"Content-Type": 'application/json',
                                          "username": securityConfig.username,
                                          "password": securityConfig.password}}
                                 )
                              .then(function(response){
                                  //console.log("string response=" + response); 
                                  var respJSON = JSON.parse(response);
                                  var respDataForDGrid = respJSON.recordset;
                                  console.log("got respJSON back, num rows= " + respDataForDGrid.length);     
  
  
                                  //================================================          
                                  // Create an instance of OnDemandGrid referencing the store
                                  console.log("Debug1");             
  
                                  var grid2 = new OnDemandGrid({
                                      collection: new Memory({ data: respDataForDGrid }),
                                      columns: {
                                          student_id: 'ID',
                                          student_firstname: 'First Name',
                                          student_lastname: 'Last Name',
                                          student_city: 'City',
                                          student_state: 'State',
                                          student_zip: 'Zip'
                                      }
                                  }, 'grid2');                                    
  
                                  console.log("Debug2");             
  
                                  grid2.startup();
                                  console.log("Debug3");             
  
                               },
                               function(error){
                                  console.log("Error=" + error); 
                                  //dom.byId('studentFeedback').value += response;
                               }); 
                      });
      });
              &lt;/script&gt; 
          &lt;/button&gt;
  &lt;h2&gt;My demoGrid - From JSON RestService (Database)&lt;/h2&gt;
  &lt;div id='grid2'&gt;&lt;/div&gt;
  
  &lt;/div&gt;  
  </code></pre>
  
  <p><strong>Part 2 -</strong> </p>
  
  <p><a href="https://i.stack.imgur.com/5EdGs.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5EdGs.jpg" alt="enter image description here"></a></p>
  
  <p>I tried mix of your code and code on this page: 
  <a href="https://stackoverflow.com/questions/17922363/how-to-reset-the-ondemandgrid">How To reset the OnDemandGrid</a></p>
  
  <pre><code>  if (grid2Registered){
      console.log("reuse existing grid"); 
      grid2Registered.set('collection', memStore);
      // refresh: clear the grid and re-queries the store for data. 
      grid2Registered.refresh();  
      }
      else{...    
  </code></pre>
  
  <p>Doc here (<a href="https://github.com/SitePen/dgrid/blob/v0.4.3/doc/components/core-components/OnDemandList-and-OnDemandGrid.md" rel="nofollow noreferrer">https://github.com/SitePen/dgrid/blob/v0.4.3/doc/components/core-components/OnDemandList-and-OnDemandGrid.md</a>) says: </p>
  
  <blockquote>
    <p>Clears the grid and re-queries the store for data. If
    keepScrollPosition is true on either the instance or the options
    passed to refresh, an attempt will be made to preserve the current
    scroll position. OnDemandList returns a promise from refresh, which
    resolves when items in view finish rendering. The promise resolves
    with the QueryResults that were rendered.</p>
  </blockquote>