Uncaught TypeError: Cannot set property '_DT_CellIndex' of undefined
Uncaught TypeError: Cannot set property '_DT_CellIndex' of undefined
Hello
I have a problem in one of my pages, where I get this error in the console_log.
"Uncaught TypeError: Cannot set property '_DT_CellIndex' of undefined"
I have other pages that display all the datatable options without problem. But this one.
All pages have the same include files (but for the specific js file).
This is a very simple page, with 2 tabs and small tables. I have been comparing the code line by line with a page where it works, and cannot find any difference.
Could somebody hint me where the problem might be so I can find it ? what gives this error in most cases ?
Thanks for the help
pat
This question has an accepted answers - jump to answer
Answers
SOLVED: this can help others.
A simple mistake, the table header had a column "<th></th> with no title, but the column did not exist in the table itself. I could not see it missing (because o no title and no borders).
Was helped by looking at the line in the datatable.js which gave the error - was implying a tr was at fault, so looked more carefully at my table and not my overall code
Pat
Thanks for posting back - good to hear you've got this sorted out!
Allan
I'm also getting the same error. I checked the table headers. No issues up there.
This issues occurs only when data is not available for the table.
Do we have any other way to fix this issue ?
Can you link to a page showing the issue please.
Hi,
I seem to have the same issue:
http://stackoverflow.com/questions/37080190/datatable-breaks-nested-repeater-and-bootstrap
I only have 1 table showing, but use 2 repeaters...
In the DOM my tables is formed properly, but says I have a non matching table elements...
Please HELP!
Happy to help - as requested in my post above, please link to a test page showing the issue so it can be debugged.
Allan
In a dataTable that has 0 entries, but has a column with no title or a title of just ( ). (For example a column for action buttons that has no title), this causes a JS error like in original report.
This issue is immediately resolved once the amount of rows in table is greater than 0.
Debug information - http://debug.datatables.net/amotez
Rewriting logic to only show DataTable if entries are greater than 0 is the current workaround for me
For me the problem was that if i had no data, I was writing in my on row of colspan="# of headers" and so only 1 td for however many columns was causing the error. I removed this to find out datatables automatically provides a "no data in table row" for me!
A table with no title in a single column and no rows in the table, shouldn't be a problem.
Allan
got same error because of number of columns in table not matching the "columns": declaration .
"columns": [
{ "width": "1%" },
{ "width": "4%" },
{ "width": "30%" },
{ "width": "3%" },
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null
]
the number of "columns" declaration must match number of columns in table
The problem arises when you have a table with multiple header columns but a row in the tbody with a single <td> and a colspan set to the full width. See: http://live.datatables.net/rexixevu/60/edit
This is correct. DataTables currently doesn't support colspan or rowspan in the
tbody
.Allan
FWIW, this same error occurs if you have a <thead> inside of a <tr>.
I'm quite sure I have no idea why I might know this...
Can you show us the HTML you are using?
thead
as an immediate child oftr
isn't valid HTML.Allan
This error occurs if we specify a column index which is not valid for "aoColumnDefs", "aTargets".
For Example,
If you are working on a table with 6 columns and then if you specify the column properties like this - '"aoColumnDefs": [{ "bSortable": false, "aTargets": [0, 6] }]'
Then we encounter the error in discussion, as our max column will be 5 and we have specified 6 for "aTargets".
Yes - you will get an error if you attempt to address a column that doesn't exist.
Allan
We had the same error, what fixed it for us is changing the (target) in the datatable initialization based on the number of columns starting from 0
In our table we had 4 columns so taget: [3]
$.extend( $.fn.dataTable.defaults, {
columnDefs: [{
targets: [ 3 ]
}]
});
Yes, like the rest of Javascript, the
columnDefs.targets
option is zero indexed.Good to hear you have it working.
Allan
I am getting this error, when I used colspan. Can anyone help me out for my issue?
Are you using colspan in the
tbody
? If so, that isn't supported as discussed many times in this forum. Equally, if you are using it in thethead
you need to still have a unique cell per column.We would need a test case, per the forum rules, to be able to help any further.
Allan
"DataTables currently doesn't support colspan or rowspan in the tbody"
Auch! That bit me .
Any plans for support of colspan?
Not currently I'm afraid. Long term it would be nice, but I can't see it happening any time soon. It adds a lot of complication to things like filtering, sorting and column visibility.
Allan
datatables v1.10.15
My console show this error =>
jquery.dataTables.min.js:24 Uncaught TypeError: Cannot set property '_DT_CellIndex' of undefined at Ja (jquery.dataTables.min.js:24)
sometimes show javascript error from datatables. How to fix, please?
Post a link to a test case showing the issue and I'd be happy to look into it.
Most likely you are using a rowspan or colspan in the
tbody
, or thecolumns
array does not match the number of columns in the HTML.Allan
If it helps anyone ... when I was getting this error recently, it was NOT due to a mismatch between the number of <th></th> and <td></td> elements. It was caused by reference a non-existent column in my columnDefs, e.g.
I had this same thing and none of the ideas above fixed it for me. This one was a bit of head scratcher until I got it figured out.
My table has only two columns and I'm using a
<tr><td colspan="2"><td></tr>
from time to time. The table is syntactically correct. I'm using the colspans to separate logical sections of data.The error comes from the fact that I'm using HTML5 data attributes on the
<td>
tags. Specifically thedata-order
attribute. In this case Datatabes does not supportcolspans
on<td>
tags.To get this to work properly for me I replaced the
<td colspan="2">
tag with two<td>
tags that included thedata-order
attributes. I used the same attribute value for the row coming next so that the order doesn't get wonky when the order is changed.Hope that helps someone!
Thanks for posting that information - I'm sure others will find it useful. I really need to improve the error reporting from DataTables for that sort of thing - sorry!
You are absolutely correct - DataTables does not full support colspan. Each column must have its own unique header cell in the header. You can use a colspan in the header, but there would need to be another row which has a unique cell for each column (example).
Allan
Hello,
I'm also getting the same error is "Uncaught TypeError: Cannot set property '_DT_CellIndex' of undefined". I checked the table headers. No issues up there.
Do we have any other way to fix this issue ?
Thanks for the help
That error typically happens if
columns
and the HTML have a different number of columns defined, or thethead
andtbody
have a different number of columns defined in them. They all need to be the same.Other than that, we'd need a link to a test case showing the issue.
Allan
I have checked the number of columns in the table, and it is appropriate. But when I try to go to the table that does not have data, there is no error in console_log.