I have a report which is generated from different models and I am displaying it as a table.Is there a way to sort this table.
This is my views code:
%table
%th Tester
%th # Assigned Ics
%th # Completed ICs
%th % Completed
%th Total Estd Effort
-@cycle.release.testers.each do |tester|
%tr
%td=link_to tester.name, cycle_ic_runs_path(@cycle, :tester_id => tester.id)
%td=@cycle.ic_runs_by_tester(tester).count
%td=@cycle.complete_ic_runs_by_tester(tester).count
-percent=0
-if @cycle.ic_runs_by_tester(tester).count >0 && @cycle.complete_ic_runs_by_tester(tester).count >0
-percent=(@cycle.complete_ic_runs_by_tester(tester).count/@cycle.ic_runs_by_tester(tester).count)*100
%td=percent
%td=total_estd_effort_by_tester(@cycle,tester)
Here I want to apply sort to tester’s name and Assigned Ic’s and Completed ICs.
Please help me out with the jquery and the necessary ruby coding.
An easy way to implement sorting on tables, is to use Javascript on the client side.
Here’s an overview of some jQuery plugins for this purpose:
http://www.webdesignbooth.com/15-great-jquery-plugins-for-better-table-manipulation/
Personaly I’d recomend DataTables.js (which can also handle pagination for you).
The simplest way to use this to make HTML tables sortable, is to just call
$('#my_table').dataTable();There are of course also non-jQuery libs for doing this.