Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
First of all...THANK YOU for this great module - I love it. I've got a view using a location as a row and dates as the column. I'm sorting the view by the date field, but the columns/dates don't appear in order. When I switch the rows to the columns and vice versa, the dates appear in order. Is there a way for the table group to prioritize the column instead of the row so that the dates appear in order? I've tried changing the date display to be purely numeric (5/19/2010) but this doesn't seem to be effecting the output.
Comment | File | Size | Author |
---|---|---|---|
#3 | datesort.png | 8.79 KB | gmak |
Comments
Comment #1
becw CreditAttribution: becw commentedI've committed a fix for this--you can now set a sort order for both columns and rows.
This weird behavior was cropping up because Tablegroup groups by row first, then column, and the rows/columns would appear in the order they appeared--ie, the first item in the first row would determine the first column. This made the row order correspond with the View results order, but the column order would seem pretty arbitrary.
Comment #3
gmak CreditAttribution: gmak commentedHi,
I'm reopening this, because I am still getting incorrect sorting on dates in the column. The attached image shows a series of dates which are set to sort by ascending. But it is actually sorting by descending (as it is putting the most recent date first).
It appears that date sorting is taking only the first element of the date (in my case the day) and then sorting. For date sorting to be useful we need to find a way to making it sort by the full date.
Many thanks for a great module!
Comment #4
joecanti CreditAttribution: joecanti commentedHi,
I came across the same problem and came up with a work around - it's not ideal, but it worked well because I wanted to have the day name at the front EG Friday 15th March 2011. It saves adding complexity to the module sort options.
- Add a date format in the format 2011-03-15
- Add this to your view and sort by that so things go in the right order
- Add another date format, that which you want to display
- Rewrite the date field so that the new format is added to the old format like this, for example:
[field_date_value]
[field_date_value_1]
and then the field looks like this:
2011-03-15
Friday, 3rd March 2011
Then wrap the top date in some css and hide with CSS...eg:
[field_date_value]
[field_date_value_1]
I've wrapped this in h6 tags.
Then hide the top field with css eg:
h6 { display: none; }
Please mark as fixed if this works well for you,
All the best, Joe
Comment #5
RainbowArrayI'm not really keen on a css hack like that. It's bad for accessibility and has extra code in the client-side html for what is essentially a server-side issue.
I'm pretty sure that what's happening is that it's sorting the columns purely alphabetically, regardless of CCK type. It would be nice to have something in there that used the raw date for the sort order for date CCK fields.
I'm not sure technically how to make that happen, but I would argue this is pretty important, since a schedule is one of the primary uses of this. I just created a schedule using this, and I'm super thankful for this module, it really saved me; however, I had to use a 24-hour clock time format to get this to sort correctly. That's not the most convenient format for attendees.
Another way to fix this would be to allow a row or column to sort based on a different field than the field actually being used to group the rows and columns. That way, you could set up a field with a 24-hour clock and use that for sorting, but use a different field with a 12-hour clock for the format that displays to people.
However, I think the most natural way to fix this is to naturally sort by the raw datetime format when a date field is involved: most users would probably expect that to happen, as it does in other situations involving date fields.
Comment #6
henno.gous CreditAttribution: henno.gous commentedany updates on this matter? running into the exact same issue...
Comment #7
henno.gous CreditAttribution: henno.gous commentedAlso, it seems like when the dates are grouped in the column, the module uses the timestamp to determine if two dates are the same and the cell should be merged, rather than the output of the date formatter. Therefore, even if you use a date format that for instance formats the timestamps to "Sunday, 21 April", you can't have a merged row for a day with multiple events happening at different times... as their original timestamps differ.
Any ideas?
Comment #8
henno.gous CreditAttribution: henno.gous commentedScratch that, think I've solved all of the above.
Just don't set any sorting in the Table Group settings... then the standard sorting criteria for your view applies... which in my case worked without any problems. This also means that you can use a PHP field to output you date in a format that will allow for merging of the rows, e.g.:
Note that you have to use $data->field_data_field_date_field_date_value instead of $row->field_date, as $row->field_date just contains the NID. Fieldnames will differ from case to case, use print_r($data) to see what your field name is.
Comment #9
C-LogemannIn the past this module was only working with simple sorting of the field output as a string. From this point of view it's a feature request and not a bug.
Yesterday I committed a new solution to 7.0.x-branch: #2575019: "Sorting by key value/term weight" and "preload all terms/allowed values". It is possible to extend the new sorting based on raw field data also to use with date values. But for a date based sorting there is a need of transforming different date types. So this isn't just a minor change and I will postpone the issue.
Because D6 is near EOL I didn't invest time in this branch and change the version to 7.x-1-x-dev
Comment #10
oturpin CreditAttribution: oturpin commentedHi,
Same issue with Drupal 7.
Impossible to sort dates. I am using the "n" date format so that I get months by numerical values. The result I have is a column with months numbers unsorted even alphabetically. Did anyone identify a solution for that issue ?
Thx
Comment #11
schifazl CreditAttribution: schifazl commentedI couldn't get sorting done with the last version, so I'm using an old one. The SQL query correctly returns the ordered rows, but when rendered in the table group the order is random. It seems that with the code cleanup the sorting was broken.