AnsweredAssumed Answered

clarification on Datagrid, dGrid, onDemandGrid, store, memory etc

Question asked by schlot on Oct 23, 2013
I'm talking myself into a circle on which type of grid to use.  I'm also confused on what type of data to use with each type of grid.  In my reading, it looks like if I create a dGrid, then I should populate my data by creating 'data' and then using something like mygrid.renderArray(data).  And if I'm using another type of grid, then I should create a Memory, populate this with the data and then set the store on the grid to it?

Or do I have that exactly backwards?  I had this working in my non-AMD version with a dojox/DataGrid, but I'm trying to be a little more updated.  I have a set of functions that takes the results of series of queries, populates a floatingpane with new titlePanes containing grids that correspond to each layer that is queried.  I know my query is running and I can see I have data, but it's not formatted right, so my newly created grids are empty.  I have the proper number of title panes in my floating pane and since they have the right titles, which are based on the layer queried and the number of features returned, I feel like the query part is correct.  Only the data for the grid isn't right, so it never displays.

I am using dgrid/Grid to construct Grid. 

cleanQueryResults is executed from an all(input).then(executefunction) type set up. 

function cleanQueryResults (queryResults) {
    var successResults = [];
    var featuresFound = 0;
//run the destroyrecursive on the children, running it on the reportContainer removes container too.
    var reportCon = registry.byId("reportContainer");
    var reportChildren = reportCon.getChildren();
    if (reportChildren.length > 0) {    
     arrayUtils.forEach(reportChildren, function(w){

    console.log("queryResults.length = " + queryResults.length);
    for (i=0;i<queryResults.length;i++) {
        try {
        var featureSet = queryResults[i];
        featuresFound = featureSet.features.length;
            if (featuresFound === 0) {
                console.log("No features found in featureSet["+ i + ']');
      console.log ("process = " + i +", records found = " + featuresFound);       
        queryGeometryResultsHandler_toGrid(featureSet, i);
        }  catch (e) {
            console.log("Error caught");
function queryGeometryResultsHandler_toGrid(results, idx) {
var resultsLength = results.features.length;
//format the data for the data grid
    var featureAttributes =, function(feature){     
        return feature.attributes;
    var data = {
        identifer: "OBJECTID",
        items: featureAttributes
   var currentStore = new Memory({data:data});
    var currentStore = new Memory({
        data: data,
//build an array of field names for the grid structure
    var itemNames = [];
    var firstFeature = featureAttributes[0];
    for (var fieldName in firstFeature) {
// create layout for the grid based on current fields in the featureSet
    var currentLayout = [];
    var addField;
    var grid;
    currentQLayer = qTaskList[idx];
//except for objectid or fid, used for the row click function, skip over internal field names
    arrayUtils.forEach(itemNames, function (fieldName) {
        switch (fieldName) {
        case "FID":
        addField = { field: fieldName, formatter: makeZoomButton };
      /*  case "OBJECTID":
        addField = { field: fieldName, formatter: makeZoomButton };
        case "Shape":
        case "Shape.area":
        case "Shape.len":
        addField = {
            field: fieldName,
            label: fieldName
//create a titlePane in the floatingPane for each visible layer

    var currentLayerId = qTaskNameList[idx];//expect this to be in the same number and order as the querytasks
    var paneTitle = (currentLayerId.split('_').join(' '))+"  ("+resultsLength+")";
 tp = new TitlePane({ id: 'gridPane_'+currentLayerId, title: paneTitle, splitter:true, class:'reportTitlePane'});
    var reportCon = registry.byId("reportContainer");
// Create Grid using structure and data defined above
    grid = new Grid({id:currentLayerId+'_grid', columns:currentLayout, autoHeight:true} );          

    var currentPane = registry.byId('gridPane_'+currentLayerId);   
        if (results.features.length > 0) {
            currentPane.set("content", grid);
        //    grid.set("store", currentStore);
        }else {
            currentPane.set("content", "No features found");