我在我的Rails应用程序(4.2.4)中集成了数据表,如下所示:
的application.js
//= require datatables.js
//= require ../metronic/assets/global/plugins/datatables/media/js/jquery.dataTables.js
//= require ../metronic/assets/global/plugins/datatables/media/js/dataTables.bootstrap.js
使用的一个例子是索引页面:
<table id="students" class="datatable table table-striped table-hover table-datatable">
<thead>
<tr>
<th class="left">Nome</th>
<th class="left">Cognome</th>
<th class="left">Classe</th>
<th class="left">Codice Fiscale</th>
<th class="left">Indirizzo</th>
<th class="left">Email</th>
<th class="left">Cellulare</th>
<th/>
</tr>
</thead>
<tbody>
<% @students.each do |student| %>
<tr>
<td class="left"><%= student.nome %></td>
<td class="left"><%= student.cognome %></td>
<td class="left"><%= student.sigla_classe%></td>
<td class="left"><%= student.codice_fiscale %></td>
<td class="left"><%= student.indirizzo %></td>
<td class="left"><%= student.email %></td>
<td class="left"><%= student.cell %></td>
<td class="right">
<%= link_to 'Vedi', student %>
|
<%= link_to 'Modifica', edit_student_path(id: student) %>
|
<%= link_to 'Elimina', student, style:'color:#F00;', method: :delete, data: { confirm: 'Sei sicuro?' } %>
</td>
</tr>
<% end %>
</tbody>
</table>
这是控制器:
def index
@students = Student.all
respond_to do |format|
format.html
format.pdf do
pdf = StudentPdf.new(@students, view_context)
send_data pdf.render,
filename: 'Elenco Studenti',
type: 'application/pdf',
disposition: 'inline'
end
end
end
如果我进行搜索,错误就会消失,我只是无法弄清楚我做错了什么,我不认为索引中的错误几乎可以肯定错误在于我整合数据表的方式。
其余一切正常,表格显示正确的分页。