Reputation: 928
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
[email protected] do |tester|
%tr
%td=link_to tester.name, cycle_ic_runs_path(@cycle, :tester_id => tester.id)
%[email protected]_runs_by_tester(tester).count
%[email protected]_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.
Upvotes: 0
Views: 96
Reputation: 3997
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.
Upvotes: 1