Bonjour, je voudrais créer une sorte de filtre sur la table suivante :
<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>
La colonne "Etat" contient sur chaque ligne l'une des trois valeurs
suivantes : "Avertissement", "Information", "Urgent".
Le principe est d'utiliser 3 boutons radio (un bouton "Avertissement",
"Information", "Urgent"). Lorsque le l'un des boutons est cliqué, la
table n'affiche que les lignes ayant l'état correspondant. Par exemple,
si je clique sur "Urgent", la table n'affichera que les lignes possédant
l'état "Urgent".
on 2012-02-22 07:52
on 2012-02-28 18:47
Je te conseille le plug-in jquery Datatable: En jouant sur les filtres et les événements, tu devrais arriver à ce que tu souhaites. http://datatables.net/
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.