AnsweredAssumed Answered

Map Viewer Template Sorting

Question asked by dhuerter@CO.WELD.CO.US_weldgov on Jan 7, 2020
Latest reply on Jan 13, 2020 by ESoekianto-esristaff

I'm working with the Map Viewer template and I want the results returned from the Feature Search (SearchPage.qml) to be sorted.

 

I have a web map with 8 layers with 3 layers that have searching enabled.  For example I have a layer of parcels that I search by Owner Name and a Subdivision layer that I search by Subdivision Name.  When the results are returned I would like to have the Parcel results sorted by Owner Name and the Subdivision results sorted by Subdivision Name.  

 

As an example - when I search for Carlson (an owner name and a subdivision name) (or a floor cleaner and a dessert topping) I get the following unsorted results:

 

My users would really like the results to be sorted within each layer.  I've attempted to add orderByFields to the SearchPage.qml in the QueryParameters with mixed results.

    QueryParameters {
        id: featureParameters
        maxFeatures: 50
        orderByFields: [
            OrderBy {
                fieldName: "NAME";
                sortOrder: Enums.SortOrderAscending
            }
        ]
    }

Adding this also requires
featuresModel.sortByStringAttribute("layerName") to be changed to
featuresModel.sortByStringAttribute("NAME") in SearchPage.qml -> onFeatureSearchCompleted:

This works for the Parcel layer but not for the Subdivision layer.  It obviously only works for one layer.  I'm unsure how to add distinct query parameters for each layer that is being searched.  Doing this also drops the search results from the Subdivision layer.

 

I've looked at the sorts in CustomListModel.qml, but I've been unable to achieve my desired sorted results.

 

How can I modify the Map Viewer Template to sort the results of a feature search for each searched layer in my web map?

 

I'm sure there is a simple and elegant solution to this problem.  Any insight that you can provide will be greatly appreciated.

Attachments

Outcomes