AnsweredAssumed Answered

Populate a grid once edits have been applied

Question asked by schlot on Dec 17, 2015
Latest reply on Dec 17, 2015 by schlot

In this project the user can enable a buffer tool.  When the select a city, it selects the counties within a buffer distance, summarizes the populations of those counties and adds these as attributes to a circle I'm adding as a graphic in my buffer layer.  It's sort of like Select with Feature Layer | ArcGIS API for JavaScript , except the information is stored in my featureService, so the user can keep the summaries they generate.

 

I have two different years of data.  To manage this, I have two different layers in my featureService, one for current and one for projected.   In my footer, I have two different grids that represent the summary values for each of the two layers.  I have a tab container with content panes for my grids. 

 

When I tested all this out, I only had one layer.  Now that I've introduced the 2nd, its grid is not populating.  I can look at the featureService and see there are graphics getting added to the 2nd layer.  However the function I have for populating the grid never fires.  The grid itself seems to be getting created, it's just empty.

 

I have some event listeners set up:

   initEvents:function (){                        

     on (app.bufferLayer_p, 'edits-complete', function (adds,updates,deletes){

        console.log("your edits are complete in bufferLayer_p");

        myGrid.populateGrid(app.bufferLayer_p,app.totalsGrid_p);

      });

     

      on(app.bufferLayer_p, "error", function (err){

       console.log("error in bufferLayer_p: " + err.message);

      });

      

    on.once(app.bufferLayer_p, 'update-end', function(){

      console.log("update-end on app.bufferLayer_p")

     myGrid.populateGrid(app.bufferLayer_p,app.totalsGrid_p);

    });

   

    on (app.bufferLayer_c, 'edits-complete', function (adds,updates,deletes){

        console.log("your edits are complete in bufferLayer_c");

        myGrid.populateGrid(app.bufferLayer_c,app.totalsGrid_c);

      });

     

      on(app.bufferLayer_c, "error", function (err){

       console.log("error in bufferLayer_c: " + err.message);

      });

      

    on.once(app.bufferLayer_c, 'update-end', function(){

     myGrid.populateGrid(app.bufferLayer_c,app.totalsGrid_c);

     console.log("update-end on app.bufferLayer_c")

    });

    }

It doesn't look like the update-end event is ever firing for my 2nd layer, the one I'm calling app.bufferLayer_p.

 

If I could figure out how to use js-bin for something this complicated, I would.  Instead, I'm attaching my code.   In order to try this out, you must A) open the buffer tool

B) Click enable buffer

C) zoom in closer to the map so you can see the cities.   The idea is that we're looking at statistics centered around a specific town, so the buffer will have an attribute for City.

Attachments

Outcomes