Table filter

Bonjour,I’d like to filter the following table

Nom salle Nom machine Type d'incident Informations Etat Date création Date résolution Actions <% @events.each do |event| %> <% # change background for event updated less than 3 minutes ago if 3.minutes.ago.to_formatted_s(:db) < event.date_resolution tr_class = ' class="bg_orange"' else tr_class = '' end %> > <%=h event.room_name %> <%=h event.computer_name %> <%=h event.type_event %> <%=h event.event_info %> <% if event.state_event=="1" %><%=h "non résolu" %> <% else %><%=h "résolu" %> <% end %> <%=h event.date_creation %> <% if event.state_event=="1" %><%=h "non résolu" %> <% else %><%=h event.date_resolution %><% end %> <%= link_to image_tag("icons/zoom.png", :title=>"Afficher") , url_for(:controller => "events", :action => "show", :id => event.event_id) %> <% if current_user %> <%= link_to image_tag("icons/edit.png", :title=>"Modifier") , url_for(:controller => 'events', :action => 'edit', :id => event.event_id) %> <%= link_to image_tag("icons/delete.png", :title=>"Modifier"), { :action => "destroy", :id => event.event_id}, :confirm => 'Are you sure?', :method => :delete, :form_class=> "toto" %> <% end %> <% end %>

The “Etat” row contains on each line one of the three following value :
“Avertissement”, “Information”, “Urgent”.

I want to used 3 radio buttons (named “Avertissement”,
“Information”, “Urgent”). While one of the buttons is clicked, the table
only displays the matching lines. For example,
if the “Urgent” button is clicked, the table will only display the lines
with the “Urgent” cell on it. Can anyone help me ?

On Wed, Feb 22, 2012 at 01:57, Tony N. [email protected] wrote:

I want to used 3 radio buttons (named “Avertissement”,
“Information”, “Urgent”). While one of the buttons is clicked, the table
only displays the matching lines.

Sounds like a job for JavaScript adding and removing visibility on the
items, possibly via setting whether CSS says their particular classes
are visible or not. Also I’d recommend an “All” option.

-Dave


Dave A.: Available Cleared Ruby on Rails Freelancer
(NoVa/DC/Remote) – see www.DaveAronson.com, and blogs at
www.Codosaur.us, www.Dare2XL.com, www.RecruitingRants.com

I agree with Dave - this is probably the easiest way to do it.

However, if your requirements to this table are expected to grow (like
Sorting, filtering on arbitrary content, row-selections etc.) you may
want to take a look into DataTables(http://datatables.net/) . I’m
using for almost all of my tabular data, as it gives you so much
functionality for free and is painless to integrate (Although it may
be a terrible overkill in your case right now…)

cheers
Stefan

On 22 Feb., 15:15, Dave A. [email protected]