I'm evaluating CiviCRM for my organization and noticed something about the demo report tables that concerns me. Hopefully I'm just missing something. Do I have to create a new report or modify an existing one in order to change the sort order of a field? For example, I'd like to view the Contribution Details report and quickly sort it by amount, but when I click on the amount column header, nothing happens. Why can't I sort by amount by clicking on its column heading? Did CiviCRM used to have that capability but there was a bug that caused problems, so you took it out?
4 Answers
How a report is sorted is defined in the Report Criteria. Depending on what data the report looks at, you can sort of different criteria. It's usually called something like "Order by columns" and appears below the Selected Columns. Reports generally sort in date order.
If you want to play about with the data, the easiest thing to do is export to CSV and save in Excel so you can sort, filter and build graphical representation of your data as you wish.
Something I did once was to apply DataTables to the output of a CiviReport, adding the necessary JS in the template. That let me sort by whatever column. It was a bit of a hack though. Not a good idea if your report has an alterDisplay function (eg. to make a contact name into a link to that contact). I also had to override CiviReport's limit() function so DataTables would see all the rows. But now I understand CiviReport a bit better as to what I can put in the configuration array.
I can't explain why the Column Headers trigger a 'mouseover' action that makes it look like you should be able to click to sort. But if that is 'how it is' and if you are using Drupal, it can be pretty quick to fire up a View that gives you the same columns and which is click sortable.
I'm reasonably sure that this is a feature available in CiviCRM 4.7 (the upcoming release, in 2-3 months) - I'm pretty sure that during the code sprint in Colorado, the DataTables plugin was applied to tables to address this. I haven't seen it in action though!
-
1This was discussed at the sprint, but unfortunately is complicated because of the some of the gotchas that DaveFF describes above. DataTables on CiviCRM Reports won't be included in 4.7. Commented Jul 29, 2015 at 15:00