I have Parks Finder all set up and ready to go, but I have noticed that when you do a "Search by Activity" the search results are displayed in random order in the Info Pods "Search Results". I would like the results to be sorted alphabetically. I notice that when you do a search by name the results are shown alphabetically, and I found the following bit of code in the locator.js file that I believe accomplishes this:
featureSet.sort(function (a, b) {
var nameA = a.name.toLowerCase(),
nameB = b.name.toLowerCase();
if (nameA < nameB) //sort string ascending
{
return -1
} else {
return 1
}
});
I added this same bit of code into the LocateFeaturebyActivity() function and it does not cause any errors, but it also does not solve the problem. The parks are still listed in random order (basically the same order they show up by default inside of ArcMap).
Does anyone have any suggestions on how I could fix this issue?
Thanks a bunch.
Solved! Go to Solution.
I figured it out. The sort function needs to go into the 'ExecuteQueryForFeatures' function after the line for setting the variable tbodyFeatureList.
var tbodyFeatureList = dojo.create("tbody", {}, tableFeatureList);
// I added this section in to sort the featureSet. - - Christine
featureSet.sort(function (a, b) {
if (a.name > b.name) {
return 1;
}
if (a.name < b.name) {
return -1;
}
// a must be equal to b
return 0;
});
// End of section I added to sort the featureSet - Christine
I hope that helps someone else!
I figured it out. The sort function needs to go into the 'ExecuteQueryForFeatures' function after the line for setting the variable tbodyFeatureList.
var tbodyFeatureList = dojo.create("tbody", {}, tableFeatureList);
// I added this section in to sort the featureSet. - - Christine
featureSet.sort(function (a, b) {
if (a.name > b.name) {
return 1;
}
if (a.name < b.name) {
return -1;
}
// a must be equal to b
return 0;
});
// End of section I added to sort the featureSet - Christine
I hope that helps someone else!