Populate a grid once edits have been applied

2675
2
Jump to solution
12-17-2015 09:13 AM
TracySchloss
Frequent Contributor

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.

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
thejuskambi
Occasional Contributor III

Hello Tracy,

In the myBufferTools.js, where you create the ToggleButton, In the onChange event you are just setting the visibility of the app.bufferLayer_c only and not for app.bufferLayer_p hence, the 'update_end' event is not being fired for that layer. if you change that then the other grid will also populate.

Hope this was helpful.

Thejus

View solution in original post

0 Kudos
2 Replies
thejuskambi
Occasional Contributor III

Hello Tracy,

In the myBufferTools.js, where you create the ToggleButton, In the onChange event you are just setting the visibility of the app.bufferLayer_c only and not for app.bufferLayer_p hence, the 'update_end' event is not being fired for that layer. if you change that then the other grid will also populate.

Hope this was helpful.

Thejus

0 Kudos
TracySchloss
Frequent Contributor

I thought I'd combed through all instances of app.bufferLayer_c and added in app.buffer_p.  Obviously not.   I was making this much too complicated!

0 Kudos