I have what I think is a fairly simple view. I am trying to create a user list with all the users who are authenticated. I am using fields like "User: Last Name". I filter by active users and the address field I added not equal to 0. I then expose a sort on Last Name and a sort on Address. When I change the selection, the list order changes, but I have no idea what order it is in, it certainly is not in order by either field. If I click on any of the field headers, they don't sort properly either. Charles does not come before Alexander ;)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

merlinofchaos’s picture

Can you please provide an export of your view? Typically this is some kind of user error, where the tablesort and the regular sort are being combined in a way that doesn't appear to make sense. We can look at an export and see if that kind of thing is happening.

flightrisk’s picture

FileSize
24.78 KB

Well you clued me into something. I had no idea there were two different sorts. I *think* I want the regular sort since that is more end user friendly. You expose the sort and they click on it. I did have a table sort set and the regular sort. I unchecked all the sort boxes in the table sort and the address sort works, all the numbers for the addresses ascend correctly. However, Last name still is not sorting correctly. I guess I will delete the regular sort and try a table sort. I didn't want to do that because then I would have to create them again. Drupal needs an "active" checkbox for sorting so you can turn it on and off without deleting it. Attached is my export.

merlinofchaos’s picture

Interesting. Override normal sort is on, so that's actually correct.

When you preview the view, there should be an info box that gives the query it generates. (You may need to visit the settings page to enable this). Can you paste the query it generates while the last name sort is failing?

Also, does putting the last name sort in the "Sorts" section have the same behavior as using the table clicksort?

flightrisk’s picture

If I delete the regular sort and use the table click sort instead it works. I had 2 sorts so that my exposed dropdown could search by last name or by address. They are now gone an I went back into the table click sort and had to add titles to the fields that I had no titles for. I then checked the checkboxes for the fields I wanted to sort by and that works perfectly. I may go back add the regular sort fields back and uncheck everything in the table click sort to look at the query that is generated again. But I think I like the click sort now. I'll just include some text above the table explaining to users they can click the headings to sort by that column.

flightrisk’s picture

please delete

dawehner’s picture

Status: Active » Closed (won't fix)

Update status.

Pedro Lozano’s picture

Title: Sorting in table doesn't work » Sorting in table doesn't work when sort criteria is exposed
Priority: Major » Normal
Status: Closed (won't fix) » Active

This is still present.

The problem is that if you _expose_ your sort criteria the table clicksort doesn't work.

Pedro Lozano’s picture

This patch fixes the problem by ensuring we respect the priority that the display handler has on building the sort (as seen on views->build()).

What this patch doesn't do:
* Make sure the exposed form default sort value matches the clicksort value.
* It doesn't add an option to make this behavior optional.

Simon Georges’s picture

Status: Active » Needs review

Changing status, as there is a patch.

thedavidmeister’s picture

Here's something for 6.x-3.x as I was having the same issue with click sorts in tables (and VBO tables) not working as soon as I exposed a sort on the view.

I'm not totally convinced that what I've done is the best way of handling this as $view->style_plugin->active and $view->style_options['override'] could exist together on a non-table style plugin and mean totally unrelated things leading to weird bugs. Would have been nice if 'override' was 'override_sort' instead but that's life.

I'd love to hear an alternative way of doing this from someone who is actually familiar with the Views code - I've just been dropping backtraces around until I could find where my 'orderby' was being dropped.

Status: Needs review » Needs work

The last submitted patch, 1333932-allow-clicksort-for-exposed-sorts-6.x-3.x-10.patch, failed testing.

thedavidmeister’s picture

patch applies fine. Tests failed because it's for 6.x and the issue is 7.x

tim.plunkett’s picture

Assigned: Unassigned » dawehner
Status: Needs work » Reviewed & tested by the community

I think the D7 fix looks sane. I opened a D8 issue for it: #2014745: Exposed sorts break custom style plugin sorting

I'd say #8 is RTBC.

dawehner’s picture

Yes this patch makes sense, but couldn't you also just configure "overide" in the table settings?

dawehner’s picture

Version: 7.x-3.x-dev » 6.x-3.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Thank you for the patch and the manual testing.

Committed and pushed to 7.x-3.x

Chris Matthews’s picture

Issue summary: View changes
Status: Patch (to be ported) » Closed (outdated)

The Drupal 6 branch is no longer supported, please check with the D6LTS project if you need further support. For more information as to why this issue was closed, please see issue #3030347: Plan to clean process issue queue