Web Report Generation made easy

With every management system you need good reporting tools and by reporting tools I mean tools which help you in creating beautiful and functional reports requiring minimal coding and very less user effort on the front end. Here is where JQueryDatatable comes in. If you need table functionality in your website and you do not want to write code for table functions like sorting, styling, searching , paging ,exporting etc. JQuery Datatables is your blessing in disguise. 

Coming on to my project , I needed to generate custom reports according to user's needs from a master report containing everything . My approach was as follows : I extracted all the required data from my database , bind that data with a normal HTML table and then applied JQuery Datatable to it. With that I got the functionality to hide columns on specific events , sort table column wise automatically on header click ,add and remove rows dynamically and refresh the table with new source without reloading the whole page. 

How it helped me ?

 First of all I supplied user with the option to hide or show any row he/she wanted in their custom report , provided few filter options and then provided the functionality to save that table by storing the columns visible . The next time when the user logged although whole of the table will load but the user will see only the columns which he saved previously. By this I get the functionality to generate unlimited number of custom reports from the same source file. 

Now a new Question that arises is, how did i store the columns?

What I did is that for each column visible I used a 1 and for every column invisible I used a zero. for total 25 columns I would get a binary string  digits long . I converted that into a BigInt number and stored that in my database with the userId of the corresponding user.

Example :- 

$ColumnsBinary =  0101011010101010101000101;

$ColumnsBigInt =  base_convert ( $ColumnsBinary  , 2 , 10 );

here I would store the value $ColumnsBigInt into the table and to show the report i would extract the the number , convert it back to decimal and parse it for 0,1 to see which column in visible and which is invisible.

One good thing supported by Datatable Plugin is that you get the option to export only visible columns to excel which made my life that much more easier. 

Another important feature which helped me a lot was the search functionality. You can easily search for a word or combination of words and can export the result to excel pdf or csv formats. This saves you the burden of making reports for every subcategory as you can filter the subcategory from the master table and export only the result.

Some drawbacks which I noticed are that playing with datatable styling is just sheer pain in the ASS and I  would recommend you not to do so . Another thing which I found a bit tricky was the ajax refresh of the source and binding the datatable without reloading the whole page. For beginners having less knowledge of Ajax ,this process could be a bit difficult. I even think that documentation of the whole plugin could be much more detailed with detailed code display for working examples and in-depth description for tricky aspects. 

But still if your are looking for extensive use of tables in your application then Datatables is a must for you.

I did not put a lot of code in this post as you can find most of it on the website mentioned below.


Post a Comment