Select to view content in your preferred language

Parks Finder - Sort Activity Search Results Alphabetically

2684
1
Jump to solution
11-10-2014 03:38 PM
ChristineCarrelli
New Contributor

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.

0 Kudos
1 Solution

Accepted Solutions
ChristineCarrelli
New Contributor

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!

View solution in original post

0 Kudos
1 Reply
ChristineCarrelli
New Contributor

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!

0 Kudos