Table View Sortable=yes is not sorting the table
| Project: | Views |
| Version: | 4.7.x-1.5 |
| Component: | User interface |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
When editing a view (specifically a table view), under the fields section, when changing sortable to "yes", and then when viewing this view the table is still NOT sortable. I've heard when sort criteria is defined that this affects the sorting ability, but I have no sorting criteria defined. A user in IRC was also wondering about this so I feel like I'm not the only one with this issue. However, I have modified some of my css. This modification wouldn't have an effect on this would it?
The default sort is working fine, displaying the table initially by the default sort. I just don't have anything to click to re-sort the table.
Drupal Version 4.7.6 (I don't know the specific number after the hyphen).
Any help is greatly appreciated. Thanks.

#1
In Views 5.x-1.6-beta5 (dunno about 4.7x-1.5), not all fields are sortable, annoyingly. Node reference and taxonomy fields aren't sortable even though the URL of a sortable column name (like ../node?sort=asc&order=Sortable_Column) can be replaced with the unlinked column name (../node?sort=asc&order=Unsortable_Column) and the sort still happens. Seems like a bug to me... Sorting should also optionally use javascript (client-side) instead of having to make a call to the database (server-side).
#2
Fields are set to not sortable if the field isn't a simple field that can be easily sorted. We didn't set these fields not sortable randomly just to annoy you; we did so because they can't easily be sorted.
Views just uses the default Drupal tablesort code, so any ajax/javascript feature requests go there.
#3
Er, what's so difficult about sorting a table column? It's not that hard to take the first character in the cell, compare it to other first characters in other cells, and sort it...
#4
You're right.
Please go ahead and write the proper code to sort that field in the query and then everything will be just fine.
Alternatively, when I give you an explanation, give me some lip.
I don't have the time, energy or interest to give you a lesson on SQL. If you want to know "what's so hard about the sorting" I suggest you learn PHP and SQL and understand the what's going on. Until you have done this, you get my explanation above. If my explanation isn't good enough for you, that's tough.
#5
And yet, when changing the URL to sort on another field, it works. <blink> Methinks your explanation is screwy, ol' Merlin...another look at your wizardry book might be in order... Perhaps consult some sortable table javascripts too.
#6
This isn't about sorting a table you moron, it's about sorting SQL.
Seriously, what are you doing in the Views' issue queue when you don't seem to have the first clue what Views actually does?
#7
Ah, so now you start with the namecalling? Typical...
I may not know what all Views can do, but I'm finding out what it can't do every time I use it. The latest bug is when a taxonomy field is used vs. an integer field; why is the integer field sortable but not the simple taxonomy field (which just so happens to also have only integers)? Uh...yea...great MySQL comprehension there by the Views devs, eh?
Go client-side (i.e. javascript) if it's too difficult to do it server-side, I say...
#8
We await your code, server side or client side, with great anticipation.
COTABUWA
#9
See above for a Google search result to several. :)
#10
You misunderstand me. I mean, as most people capable of the most rudimentary understanding of the English language (is it not your primary language?) would understand, your contributions to drupal which accomplish that which you believe to be simple to do. Just a simple request to put your code where your fingers are.
Please drop the smiley. You have long ago lost the right to be cutesy in this thread.
#11
I didn't misunderstand you at all, actually. You asked for something server- or client-side, I gave you links to client-side javascript sortable table scripts. Go nuts. Knock yourself out (multiple times, even). :D <-- Just for you, li'l buddy.
#12
And yet you fail to understand why client side sorting is the wrong answer. This leads back to "Please understand what Views does". Since you clearly refuse to, please get out of my issue queue.
#13
How can I fail to understand you haven't even bothered to give a good reason against? Duh. Oh and this isn't your issue queue; you don't own Views (and this issue isn't even assigned to anyone anyway).
#14
Eep.
A couple of quick notes: first, merlinofchaos is, in fact, the developer who owns the Views project and maintains it. So. it is his issue queue. ;-)
Second, Views uses the built-in table rendering mechanism that's part of the Drupal core, and Drupal core uses server-side table sorting to preserve the ordering of long lists that are being displayed in a pager view. The reason that the style of sorting you describe hasn't been added to the system is simple: it breaks down nastily whenever there are more items being displayed than can fit on one page. Here's an illustration:
Server-side sorting
[Page 1]
Aardvarks
Bonobos
Crocodiles
Ducklings
[Page 2]
Elephants
Fireflies
Gorillas
Humpback Whales
[Page 3]
Iguanas
...
And so on. Because Drupal is sorting all of the items, and sending a particular 'chunk' of them at one time, it's speedy and preserves the ordering as the user pages through the list. If, however, you use client-side sorting to rearrange the items, you get the following:
Client-side sorting
[Page 1]
Ducklings
Crocodiles
Bonobos
Aardvarks
[Page 2]
Humpback Whales
Gorillas
Fireflies
Elephants
[Page 3]
Iguanas
...
It makes trying to find items in the larger list REALLY difficult. The other option, sending ALL the items to the client side, isn't feasible because many of these paged lists have thousands upon thousands of items.
The upshot is, solutions that get rolled into mission-critical apps like Views and Drupal core have to work reliably in the majority of scenerios that are thrown at them. Client-side sorting of large lists doesn't, at least not yet. Solving it is almost certainly possible but is currently a low priority. There are bigger fish to fry at the moment, and if the need is great then another dev is welcome to write a client-side table sorting module that adds that behavior to Drupal tables. Using jQuery, it would in fact be possible.
#15
What an informative, pleasant post, Jeff. Didn't you feel like using a bullet instead?
#16
Jeff, that is one amazing response.
I'm so outclassed here, only the truest of geeks could stay focused on the issue in question in the face of such rudeness and ignorance.
#17
Thanks Eton for the explanation. What I was wondering was why can't the clent side sorting sort in the usual Alphabetical order like the following even if it only has one page worth of data:
[Page 1]
Aardvarks
Bonobos
Crocodiles
Ducklings
Why would the order reverse as you say in your example?
#19
Jeff was only providing an example scenario: "What if you wanted to sort the list in reverse alphabetical order?"
He showed how that scenario would break down because each page only has access to a chunk of the data.
If you wanted to sort this client-side in alphabetical order, then yes, it would work, but only because alphabetically was the default ordering to begin with.
It's really hard to believe that Eep has enough intelligence to use a computer, learn about Drupal, figure out how to post on an issue queue, AND THEN at the same time be such an ignorant bastard. Just unreal...