Html表TD和TH与jquery数据表不匹配

时间:2018-05-25 22:37:33

标签: javascript jquery html ruby-on-rails datatables

我在rails中使用rails Jquery数据表它说你的th和td计数应该匹配,如中所述 https://www.gyrocode.com/articles/jquery-datatables-common-javascript-console-errors/#typeerror-cannot-read-property-mdata-of-undefined

每当我对上面附带的代码进行注释时,它都会显示错误 在控制台

enter image description here

如果我不使用colspan,它的工作正常

<table class="table table-striped table-bordered add-data-table-view">
  <thead>
    <tr>
      <th>Sr No</th>
      <th>Name</th>
      <!-- <th colspan="2">Action</th> -->
    </tr>
  </thead>
<% @i = 0 %>
<% count = ((params[:page] || 1).to_i - 1)*10 +1  %>
  <tbody>
    <% @designations.each_with_index do |designation, i| %>
      <tr>
        <td><%= count + i %></td>
        <td><%= designation.name %></td>
        <!-- <td><%= link_to 'Edit', edit_designation_path(designation) %></td> -->
        <!-- <td><%= link_to 'Destroy', designation, method: :delete, data: { confirm: 'Are you sure?' } %></td> -->
      </tr>
    <% end %>
  </tbody>
</table>
<%= will_paginate @company_branches, :container => false %>

0 个答案:

没有答案