AnsweredAssumed Answered

Graphics from featureLayer - do I need to do a selection to get them?

Question asked by schlot on Sep 24, 2015
Latest reply on Sep 28, 2015 by schlot

I have a featureLayer loaded as

 app.bufferLayer = new FeatureLayer(config.pathName + "/arcgis/rest/services/DPS/VetComm_bufferAnalysis/FeatureServer/0" ,{
        id:"bufferLayer",
        outFields:['*']
        }
      )

 

I also have an onDemandGrid that shows the attributes for this layer.  When I first load the layer, I'd like to be able to populate the grid.

 

        on(app.bufferLayer, 'load', function(){
          myGrid.populateGrid();
        });

 

//function in myGrid

 

     populateGrid: function() {
     var graphics = app.bufferLayer.graphics;
       var gAttributes = arrayUtils.map(graphics, function(g){     
          return g.attributes;
       });
    var currentMemory = new Memory ({data:gAttributes, idProperty:'id'}); 
        app.totalsGrid.set('store', currentMemory);
     }

 

I'm confused about featureLayer.graphics, which is documented as as an array of graphics from the featureLayer.  When the load event executes for the bufferLayer, app.bufferLayer.graphics is an array with the length of 0.

 

If I add  graphics to this layer, I can execute this same function again, and this time, instead of the array length being 0, it now has all the previous graphics that were in bufferLayer, along with the new feature I added.  The grid gets populated with everything.

 

          on (app.bufferLayer, 'edits-complete', function (adds,updates,deletes){
            myGrid.populateGrid();
          });

 

I can run a query against the bufferLayer once it's loaded and use the results to populate my grid initially, but it seems like extras steps, since from the documentation is sounds like I can get all the graphics from the layer without doing all that. 

Outcomes