Select to view content in your preferred language

dgrid refresh

5613
10
Jump to solution
02-12-2014 07:47 AM
MichelleRogers1
Occasional Contributor
I am working with a feature layer that refreshes every 5 seconds.  I would like my dgrid to refresh also, so it is giving the most up-to-date information.  I have tried inserting the code: grid.refresh(0.083); in many places throughout my code, but the grid is not updating at all.  I am using a memory store, could this have something to do with why my grid won't refresh?  The code I am using to populate the grid is as follows:

function populateGrid(Memory) {             [INDENT]var qt = new QueryTask(window.unitsUrl);             var query = new Query();            [/INDENT]  query.where = "1=1";              query.returnGeometry = false;              query.outFields = window.outFields;              qt.execute(query, function(results) {   var data = [];   var data = array.map(results.features, function(feature) {                    return {                       // property names used here match those used when creating the dgrid                       "id": feature.attributes[window.outFields[0]],                       "vehicleId": feature.attributes[window.outFields[1]],                       "velocity": feature.attributes[window.outFields[2]],     "timestamp": feature.attributes[window.outFields[3]]    }                 });   //if (!grid) {    //grid = new Grid({     //columns: {      //"id": "ID",                    //"vehicleId": "Vehicle ID",                    //"velocity": { "label": "Speed (MPH)", "formatter": dojoNum.format },      //"timestamp": "Time Stamp"     //}    //}, "grid");   //}   //grid.refresh(0.083);               var memStore = new Memory({ data: data });                 window.grid.set("store", memStore);  }); }


Also, the code where I am calling that function is as follows:

map.on("load", function( evt ){              // show the border container now that the dijits               // are rendered and the map has loaded              domStyle.set(registry.byId("container").domNode, "visibility", "visible");              populateGrid(Memory); // pass a reference to the MemoryStore constructor         });


Any help in getting this to refresh is greatly appreciated.

Michelle
0 Kudos
10 Replies
MichelleRogers1
Occasional Contributor
That was the ticket!  My grid is finally refreshing, thanks!  I did end up having to still call the request because when I zoomed in to one point, the grid only had the one point in it.  By making another request with the Query and QueryTask, I was able to zoom, but still have all vehicles on the list.

Do you know if there's a way to sort the grid on one field?
Also, when I zoom, the feature layer stops refreshing, but the grid still does.  Is there something in my code that is causing the feature layer to stop refreshing when it zooms?


Nevermind on the sorting, I just figured it out.  I am perplexed as to why the feature layer quits refreshing when I zoom to it though.
0 Kudos