Select to view content in your preferred language

OrderByFields

2319
1
02-06-2014 06:16 AM
JeffFrye
Deactivated User
Good Morning,

I am attempting to order by multiple fields. Using the sample I can successfully get the sort to work in one field, but I want it to sort by 'Field A' and then 'Field B'. In the code below "FULLNAME" is my Field A and "PREADDRNUM" would be my Field B.

I have spent 2 days searching for a solution. I did find a C# version, but I have not been able to convert it properly.

Can someone help me with this?  Thank you

Dim addressQuery As Query = New ESRI.ArcGIS.Client.Tasks.Query()
        addressQuery.OutFields.Add("*")
        addressQuery.ReturnGeometry = True
        addressQuery.Text = AddressBox.Text
        addressQuery.OrderByFields = New List(Of OrderByField)() From {New OrderByField("FULLNAME", SortOrder.Ascending)}
        addressTask.ExecuteAsync(addressQuery)


I placed this SUB in here because in the C# version I saw the order was set in this event.

Private Sub FindTask_ExecuteCompleted(sender As Object, e As QueryEventArgs)
        AddressGrid.Visibility = Windows.Visibility.Visible
        Dim featureSet As FeatureSet = e.FeatureSet


        If featureSet IsNot Nothing AndAlso featureSet.Features.Count > 0 Then
            AddressGrid.ItemsSource = featureSet.Features
        Else
            MessageBox.Show("No features returned from query")
        End If
    End Sub
0 Kudos
1 Reply
JeffFrye
Deactivated User
I actually resolved this myself.

Place the second field behind the first one separated by a comma as such:

addressQuery.OrderByFields = New List(Of OrderByField)() From {New OrderByField("FULLNAME, PREADDRNUM", SortOrder.Ascending)}
0 Kudos