dgrid displays but does not populate with query results

2786
4
Jump to solution
10-26-2012 04:15 PM
DerekMiller
New Contributor III
Hello all,

I'm having trouble populating a dgrid. The grid draws and the query in the function to populate the grid returns an array of features from the service (written to the console), but the data does not populate the dgrid. I'm receiving no errors, and my code is very similar to an example from Kelly Hutchins that I had found in the past, but couldn't find today. Anyone have any luck with a dgrid? It would be a very nice feature to implement.

Thanks in advance for any thoughts.

Code snippets below, the full file is attached.
- derek

 require(["dgrid/Grid", "dgrid/Selection", "dojo/store/Memory", "esri/Map", "esri/layers/FeatureLayer", "esri/dijit/InfoWindow", "esri/dijit/Popup", "esri/tasks/locator", "esri/tasks/query", "esri/symbol", "esri/Renderer", "dojo/_base/declare", "dojo/number", "dojo/parser", "dojo/dom", "dojo/query", "dojo/domReady!"],       function(Grid, Selection, Memory, Map, FeatureLayer, InfoWindow, Popup, Locator, Query, Symbol, Renderer, declare, dojoNum, parser, dom, query) {         //parse the script call and the dijits         parser.parse();                  //create the dgrid         window.grid = new (declare([Grid, Selection]))({           bufferRows: Infinity,           columns: {             "globalID": "ID",             "building_name": "name"           }         }, "grid");         grid.on(".field-building_name:click", selectProject);  // universal utility to resize the map div when the browser re-sizes         dojo.connect(map, "onLoad", function(map) {           //resize the map when the browser resizes           dojo.connect(dijit.byId("map"), "resize", map, map.resize);           // show the border container now that the dijits            // are rendered and the map has loaded           dojo.style(dijit.byId("container").domNode, "visibility", "visible");           populateGrid(Memory);         });          //the following curly brace and closing parentheses are the end of the dojo/domReady! function         }   );   //end of the dojo/domReady! function         function populateGrid(Memory) {     console.log("in populateGrid");     var qt = new esri.tasks.QueryTask(window.gdaUrl);     var query = new esri.tasks.Query();     query.where = "1=1";     query.returnGeometry = false;     query.outFields = window.outFields;     qt.execute(query, function(results) {       console.log(results);       var data = dojo.map(results.features, function(feature) {         return {           "globalID": feature.attributes[window.outFields[50]],           "building_name": feature.attributes[window.outFields[1]]         }       });       var memStore = new Memory({ data: data });       window.grid.set("store", memStore);       //window.grid.renderArray(data);       console.log("populateGrid is complete")     });   }   </script>
0 Kudos
1 Solution

Accepted Solutions
__Rich_
Occasional Contributor III
You're welcome 🙂

Just click on the tick icon next to my post - thanks...

View solution in original post

0 Kudos
4 Replies
__Rich_
Occasional Contributor III
Off the top of my head, I don't think the basic dgrid/Grid has store support...dgrid/OnDemandGrid, for example, does...IIRC.
0 Kudos
DerekMiller
New Contributor III
Thanks for the response. I'll give that a shot and share the results.

- D
0 Kudos
DerekMiller
New Contributor III
Spot on, geos_rfleet, thank you.

I was using the wrong method with the wrong grid module. Now, the dgrid/Grid is populating with the renderArray method, while the dgrid/OnDemandGrid populates via the memStore.

Thanks for the help.

Interestingly, neither method populates when I pull all attributes from the service using ["*"]; (it's a big service), so I would be interested to know how many records / fields the grid can hold before it fails.

Nonetheless, this gives me something to work with. Thanks again. Where do I mark this answered so you get credit?

Regards,

- d
__Rich_
Occasional Contributor III
You're welcome 🙂

Just click on the tick icon next to my post - thanks...
0 Kudos