AnsweredAssumed Answered

DGrid error - not refreshing

Question asked by ardaiel on Dec 22, 2018
Latest reply on Dec 24, 2018 by rscheitlin

Since the feature table widget isn't ready yet, I'm using dgrid to display results of a query, as show in the "highlight features by geometry" example.  However it only works when I do a unique search.  If I do a search and it brings back feature 1, 2 and 3, then the grid shows.  I can do a second search, and it bring back features 3, 4 and 5, and the grid shows.  But if I redo the first search, and it gets the same result set - features 1, 2 and 3 - then it fails, and gives the error "TypeError: Cannot read propery 'element' of undefined, at _StoreMixin.js:2; which implies the error has to do with the datastore.  I've tried resetting the datastore, setting it to a blank array then back to the result set, etc; nothing works.  Does anyone have any ideas?  Code below:

 

function populateResultGrid(resultArray){
   document.getElementById("gridDisplay").style.display = "block";
   document.getElementById("featureCount").innerHTML = "<b>Showing attributes for " + resultArray.length + "    features</b>"
   require([
      "dgrid/OnDemandGrid",
      "dojo/store/Memory",
      "dstore/legacy/StoreAdapter",
      "dgrid/Selection"
   ],
   function(OnDemandGrid, Memory, StoreAdapter, Selection){
      var dataStore = new StoreAdapter({
         objectStore: new Memory({
         idProperty: "AssetID"
      })
   });
   dataStore.objectStore.data = resultArray;
   var grid = new(OnDemandGrid.createSubclass([]))({
      columns: getColumns()
   }, "grid")
   grid.set("collection", dataStore);
   grid.refresh();
   })
}

Outcomes