0

I'm using jQuery DataTables in two of my Rails 6 applications. In one application it works fine, in the other application I can't get it to work. I always get the following error:

Uncaught TypeError: Cannot set property '_DT_CellIndex' of undefined

In my other application this error occured when the number of header columns doesnt match the actual table columns, but those are appropriate in the actual case (2 header columns, 2 table columns).

Here's the table code:

<table id="general_feeds" class="table table-borderless text-center">
  <thead class="bg-bdh text-white shadow">
    <tr>
      <th>Datum</th>
      <th>Rolle</th>
    </tr>
   </thead>
   <tbody>
     <% @feedbacks.each do |feedback| %>
       <tr>
         <td><%= I18n.l(feedback.date) %></td>
         <td><%= feedback.role_before_type_cast %></td>
       <tr>
     <% end %>
   </tbody>
</table>

And here is my js-code to initialize the table:

$("#general_feeds").DataTable({
  "language": {
      "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/German.json"
  },
  responsive: true,
  searching: true
});

I read all the threads in the datatables forum but couldn't get it to work. I know that the plugin doesnn't support colspan etc. which I'm not using.

Any suggestions?

Max Kirsch
  • 441
  • 5
  • 24
  • One minor point - which probably is not related to your problem: Always include the protocol (`https:`) in your URLs. See [here](https://stackoverflow.com/a/60582946/12567365). – andrewJames Mar 12 '20 at 19:42
  • Thanks for your hint, I have that line from the docs :) – Max Kirsch Mar 12 '20 at 19:49
  • 1
    In your table you have `` before the closing ``. It should be ``. – andrewJames Mar 12 '20 at 20:23
  • Wow. You're right that was the problem. Holy shit I feel so dumb I looked 1000 times and didn't see it :D. It*s working now. It generated an empty row every time and broke it. – Max Kirsch Mar 12 '20 at 20:37

0 Answers0