Bonjour,I''d like to filter the following table <tr> <th><a href=#>Nom salle</a></th> <th><a href=#>Nom machine</a></th> <th><a href=#>Type d''incident</a></th> <th><a href=#>Informations</a></th> <th id="etat"><a href=#>Etat</a></th> <th><a href=#>Date création</a></th> <th><a href=#>Date résolution</a></th> <th><a href=#>Actions</a></th> </tr> <% @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 %> <tr<%= tr_class %>> <td><%=h event.room_name %></td> <td><%=h event.computer_name %></td> <td><%=h event.type_event %></td> <td><%=h event.event_info %></td> <td><% if event.state_event=="1" %><%=h "non résolu" %> <% else %><%=h "résolu" %> <% end %></td> <td><%=h event.date_creation %></td> <td><% if event.state_event=="1" %><%=h "non résolu" %> <% else %><%=h event.date_resolution %><% end %></td> <td> <%= 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 %> </td> </tr> <% end %> </table> 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 ? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Wed, Feb 22, 2012 at 01:57, Tony N. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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 Aronson: 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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
vierundsechzig-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org
2012-Feb-22 19:49 UTC
Re: Table filter
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 Aronson <googlegroups2d...-BRiZGj7G2yRXqviUI+FSNg@public.gmane.org> wrote:> On Wed, Feb 22, 2012 at 01:57, Tony N. <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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 Aronson: Available Cleared Ruby on Rails Freelancer > (NoVa/DC/Remote) -- seewww.DaveAronson.com, and blogs atwww.Codosaur.us,www.Dare2XL.com,www.RecruitingRants.com-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.