Closed (fixed)
Project:
Forena Reports
Version:
7.x-3.0-beta3
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
21 Apr 2012 at 01:48 UTC
Updated:
22 Jun 2015 at 18:13 UTC
Jump to comment: Most recent
Would like to be able to sort different columns when viewing the report. Much like Views sorting options for tables.
Comments
Comment #1
metzlerd commentedAgreed. I'm trying to figure out how to make that happen in the meanime you can create sorting for your reports in the SQL by writing queries that look like:
THen you make the table headers links to the table with the different sort parameters. reprots/testreport?sort=title
Does this make sense?
Dave
Comment #2
metzlerd commentedThe latest dev versions 7.x-2.x and 6.x-2.x support jquery dataTables plugin to provide javascript based resorting of data. Install jquery dataTables in your sites/all/libraries folder renaming the version specific extracted folder to dataTables so that you see a directory called sites/all/libraries/dataTables/media.
IF your report was named myreport, you could create a myreport.js file as follows:
You can also create a report form js file and reference that to embed datatables in multiple reports.
More information on dataTables can be found at http://datatables.net
Comment #3
SMTF commentedHi Dave
Where should the myreport.js file be placed?
I could have datatables js included in report pages via some other non Forena mechanism; however, I'd prefer to keep it bundled consistently with Forena if such a mechanism exists.
For example I can throw the following in a block displayed on the report page :
It proves things are working; however, it's obviously less then ideal.
Thanks in advance.
Comment #4
metzlerd commentedThe myreports.js file should live in the same directory and have the same name as the report (or report form) that you have created. Since writing this I sort of realized that you could (rather than using the myreports function I described) use drupal behaviors as described in:
http://drupal.org/node/171213
So if your report is named davesReallyCoolReport.frx, then you can create a davesReallyCoolReport.js file that contains much of the javascript that you need. Again, you should not be overriding document ready but rather be adding to Drupal Behaviors. In drupal 7 it would look like this.
Since you keep needing more and more added libraries. Let me recommend you creating a custom module or alternatively adding the css and js files into your custom theme. Adding js to the theme is described in document that describes the drupal behaviors concept.
If you do a custom module, you could implement hook_forena_parameters_alter to add the css files like this:
Know that this is a temporary solution until I build javascript library loading into the the forena form mechanism. (I've just started work on a 7.3 version that will implement these. )
I'll try and roll a youtube video demonstrating this and maybe a sample report as well. Hope this helps.
Comment #5
metzlerd commentedLibrary loading code was implemented, and all dataTable plugins can now be used with forena. Youtube video has been published regarding skins and walks through the problem of implemengting datatables with forena.
Comment #7
MickC commentedIs there an frx option to add into the layout that might be able to sort the same data block in a different order?
Tihs would save having to create a new data block just to have a different order.
Comment #8
metzlerd commentedThe two techniques for sorting data blocks are really described in this issue. You do not need to build a different data block, but you can create data blocks that conditionally sort data in one way or another. Some of that is hinted at in earlier comments in this issue, but there have been better tools developed since this issue was closed for doing so.
In particular, the newer SWITCH CASE statement allows you to write data blocks of the form:
Conditional SQL statements are pretty well documented in the forena 7.x-4 current beta.
Once you do this, adding conditional sorting is dependent on the data blocks.
Of course the easiest approach is still to use the dataTables javascript library to add JS sortable columns to the tables. This is also fairly well documented in the 7.x-x current (beta) release.
Comment #9
Pierre.Vriens commentedExtra info about David's latest comment: the conditional SQL docu is located in reports/help.data#conditionalsql . The dataTables docu is at reports/help.setup#datatables and includes a pointer to a video about it also. Note that the beta4 version of the docu still has some glitches that have been resolved in the current dev version already, refer to #2124777 for more details.
Since conditional SQL does not apply to data blocks in XML format, I prefer using the dataTables approach to create sortable table columns for XML data blocks.
Comment #10
MickC commentedThanks for the suggestions - I was able to use the same datablock twice with different sorts in the same report by passing a different sort parameter directly into the block, using the SWITCH CASE method in this issue and the frx:parameters method here https://www.drupal.org/node/2039039.
e.g. frx:parameters="sort=somesortfield"
Comment #11
Me Lafisu commentedHi,
I've successfully created a forena report with one parameter. My issue is when I open the report I can’t see directly my table. I should select a parameter, submit then my table is browsed.
So how can I let show my table by default? In fact I’m using the parameter as filter criteria.
Thanks in advance.
Comment #12
metzlerd commentedIf I understand you correctly, you want the parameter to have a specific value as its default, so that a report has data? This can be done by editing the parameters of the report and providing a default value.
I'd recommend creating a separate support issue for this as it doesn't seem related to this closed issue.
Comment #13
Me Lafisu commentedok thank you for your reply