... to implement a similar solution in a couple of projects I was working on, so I extracted a solution into a gem. The final goal of this gem is to generate JSON content that will be given to jQuery DataTables. All the data table customizations (header, tr, td, CSS classes, width, height, buttons, etc.) must take place in the javascript definition of the data table. jQuery DataTables is a very powerful tool with a lot of customization available. Take the time to read the doc.