我有一个表,我使用jQuery Datatables插件。我一直收到以下错误(在加载页面时以警告框的形式)。
DataTables警告:table id = example - 请求的未知参数' 10'第0行。
我一直在阅读文档,但无法掌握错误的位置。这是我的表:
<table id="example" class="table table-hover card display dataTable table_judge_tournoi">
<thead>
<tr>
<th>Exporté</th>
<th>Select</th>
<th>Prénom</th>
<th>Nom</th>
<th>Licence</th>
<th>Inscription</th>
<th class="text-center">Profil</th>
<th>Convocation en cours</th>
<th>Messages<th>
<th>Dispos</th>
</tr>
</thead>
<tbody>
<% @subscriptions.each do |subscription|%>
<tr class="subscription_item" id="<%= subscription.id %>">
<%if subscription.exported == true%>
<td>true</td>
<%else%>
<td>false</td>
<% end -%>
<% if subscription.status == "confirmed" %>
<td class="checkbox"><input class="checkbox-player" type="checkbox"></td>
<% else %>
<td></td>
<%end%>
<td class="first-name"><%= subscription.user.first_name%></td>
<td><%= subscription.user.last_name%></td>
<td><%= subscription.user.licence_number%></td>
<%if subscription.status == "pending" %>
<td>
<%= form_for [@tournament, subscription] do |f| %>
<%= f.select :status, Subscription.status.options, :confirm => 'Your confirm message', remote: true, class: "form-control subscription-status" %>
<%end%>
</td>
<%elsif subscription.status == "confirmed"%>
<td>
<div class="btn btn-success">
<a href="#" data-target="#confirme" data-toggle="modal" class="subscription_status">
Confirmé
</a>
</div>
<div class="modal fade" id="confirme">
<div class="modal-dialog mymodal">
<div class="modal-content text-center">
<div class="modal-header">
<h4 class="modal-title">Remboursement</h4>
<p>Ce joueur ne participe plus au tournoi finalement ? Vous pouvez le supprimer et procéder au remboursement de ses frais d'inscription ! <br></p>
<p> Il vous suffit de cliquer sur <strong>Rembourser</strong> ci-dessous pour que son inscription au tournoi soit supprimé et lui reverser ses frais d'inscription</p>
</div>
<div class="modal-body">
<%= form_tag refund_path(subscription) do %>
<%= hidden_field_tag :subscription_id_refund, subscription.id %>
<%= submit_tag "Rembourser ce joueur", id: "export", class: "btn btn-warning"%>
<% end -%>
</div>
<div class="modal-footer">
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
</td>
<%elsif subscription.status == "sent"%>
<td>
<p>Envoyée</p>
<%else%>
<td>
<div class="btn btn-danger">
<a href="#" data-target="#refuse" data-toggle="modal" class="subscription_status">
Refusé
</a>
</div>
<div class="modal fade" id="refuse">
<div class="modal-dialog mymodal">
<div class="modal-content text-center">
<div class="modal-header">
<h4 class="modal-title">Accepter ?</h4>
<p>Vous souhaitez finalement accepter ce joueur au sein du tournoi ? Pas de problèmes. Cliquer sur "Nouvelle demande d'inscription" ci-dessous pour que celui-ci procède au paiement en ligne </p>
</div>
<div class="modal-body">
<%= form_tag askpayment_path(subscription) do %>
<%= hidden_field_tag :subscription_id_judge_asks, subscription.id %>
<%= submit_tag "Nouvelle demande d'inscription", id: "export", class: "btn btn-warning"%>
<% end -%>
</div>
<div class="modal-footer">
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
</td>
<% end %>
<td><button type="button" class="btn btn-primary "><%=link_to "Profil", user_path(subscription.user) %></button></td>
<% if subscription.convocations.last %>
<td><%= subscription.convocations.last.status_text %></td>
<%else%>
<td></td>
<% end %>
<% if subscription.convocations.last && subscription.convocations.last.messages != [] %>
<td>
<%=link_to "+1", convocation_messages_path(subscription.convocations.last), class: "btn btn-success" %>
</td>
<%else%>
<td></td>
<% end %>
<% if subscription.disponibility %>
<td>
<%= link_to image_tag("fleche_bleufonce.svg"), subscription_disponibility_path(subscription, subscription.disponibility), class: "fleche_subscription" %>
</td>
<% else %>
<td>Non renseignées</td>
<% end %>
</tr>
<%end%>
</tbody>
</table>
这里有数据表工作的js:
$(document).ready( function () {
$.fn.dataTableExt.oStdClasses["sFilter"] = "my-style-class";
$('#example').DataTable({
"paging": false,
"ordering": false,
"info": false,
});
});
答案 0 :(得分:0)
根据DataTables manual,其中一个原因可能是:
#cells = #columns * #rows
(即标题中定义的列数多于表格中的列数,反之亦然)。我不是Ruby专家,但很可能您的代码在<td></td>
中生成的列<tbody>
多于标题<th></th>
中定义的<thead>
个元素的数量(示例中为10
)。