Download & Extend

Sort by City, Postal Code [...] is not working

Project:Address Field
Version:7.x-1.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed (works as designed)

Issue Summary

At the time it is not possible to sort by the address fields. I use the address field in a views and rewrite the output with a token. At the end of the form (click sort column) I had chosen the same as the token.

Comments

#1

Status:active» closed (works as designed)

I attached a screenshot of the sorting options for segments of the addressfield. This is implemented in Views, not directly in Address Field; so you shouldn't have to use tokens as a work-around.
screenshot.png

AttachmentSize
screenshot.png 73.01 KB

#2

I have this problem as well - the issue isn't with the "sort criteria" option in the view - that works fine. The issue is when creating a table view, and enabling click sorting on the table view, click sorting on the addressfield column doesn't work properly. It won't sort by the actual contents of the addressfield column.

#3

Thought I could get around it by creating a "Global: Custom text" field using the string value AddressField location [tokens], but unfortunately custom text fields are not sortable.

#4

Here's a screenshot of the incorrect sorting of this type of field. Assume it's sorting by the first value (in my case "organization").

AttachmentSize
Screen shot 2012-08-15 at 5.51.44 PM.png 63.13 KB

#5

Yep, mine is doing the same as #4 - I can't figure out what it's sorting on though, as my address doesn't store names or organizations.

#6

Status:closed (works as designed)» needs work

This is an active and big problem.

#7

In order to workaround this, I used auto_nodetitle to replace the node titles with the piece of the location I wanted to sort by (in my case, city) and used node title for the sort field in the view. This probably wouldn't work for most cases but it was a reasonable workaround for me.

#8

Status:needs work» active

The status of this should be "active" since "needs work" means there is a patch that needs work.

#9

Category:bug report» support request
Status:active» closed (works as designed)

Ok, I think I understand what's happening here. The issue appears to be that folks are adding an address field column to a View, rewriting the output to only show part of the address, and then expecting a click sort to sort based on the rewritten output instead of the data in the field itself. Unfortunately, that just isn't possible. Views sorting happens at the query level before the View results are ever rendered and output is rewritten. There's no way for a click sort to take into consideration just a specific part of the address when the column itself is a full address field.

If I end up committing it, this will provide the solution: #991834: Address component Views support

#10

Quite right. That's exactly it.