3

Im aware a sort() function exists, just not sure where it should be placed in my code. I have a function that draws routes on the map and i'm getting my results that are in my table from those routes. Do I put sort() after the lines are drawn, before the table is populated? or after the table is populated. Here is my code that populates my table.

myMap.Search = {
 gpGetStats: new esri.tasks.Geoprocessor(gpURL),
 getRouteStats: function () {
 console.log(dojo.byId('resultsLayer').value)
 var params = {
 "ZIP_CRID": dojo.byId('resultsLayer').value
 };
 resultsLayer.Search.gpGetStats.execute(params, resultsLayer.Search.handleStats);
 },
 handleStats: function (results, messages) {
 console.log(results);
 // content.sort();
 var content = "";
 content += '<table>';
 content += '<tr><td> ZIP CRID </td><td> Bus </td><td> Res </td><td> Tot </td><td> &lt;200 </td><td> DS Key </td></tr>';
 dojo.forEach(results[0].value.features, function (crid, i) {
 console.log(crid.attributes.ZIP_CRID + ', ');
 content += '<tr><td>' + crid.attributes.ZIP_CRID;
 content += '</td><td> ' + crid.attributes.BUS_CNT;
 content += '</td><td> ' + crid.attributes.RES_CNT;
 content += '</td><td> ' + crid.attributes.TOT_CNT;
 content += '</td><td> ' + crid.attributes.LT_200_IND;
 content += '</td><td> ' + crid.attributes.DS_KEY + '</td></tr>';
 });
 content += '</table>';
 dojo.byId('details').innerHTML = content;
 },
}

Also a Dojo Grid would be acceptable

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Jun 21, 2013 at 17:39

1 Answer 1

2

Do you have control over the GP service? If so, might be the most efficient place to sort the results as it does not require work for the client and you would not have to worry about hitting the max record limit returned by a GP service. However, it is possible to sort the results in javascript: http://davidwalsh.name/array-sort

Here is an example of using a grid: https://developers.arcgis.com/en/javascript/jssamples/find_map_datagrid.html

answered Jun 22, 2013 at 19:50

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.