I am not be able to resolve following Datatables error:
SCRIPT5007: Unable to set property '_DT_CellIndex' of undefined or null reference
I tried to look all over the internet and found this to be the best solution. But I am still not able to resolve this issue. Am I missing something here? I am a newbie in JavaScript.
I fixed it. It was js part vs html.
Problem happened when I deleted html column and forgot to delete a js column that looked like this.
Once I deleted the extra column in js everything started working.
found this answer here: datatable forums
did it work?
To solve the error:
First I tell you that
$("id_tu_tabla").Datatable()
have a minimum number of columns, it is 6. But if you have less than that, you have specify it, like with this code: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]
It seems like many people got the error because of th and td mismatch. For me I got the error with what seemed to be a logical error. Look the code below.
Note: This was me experimenting with datatables in Angular 7, enhance things like *ngFor, ng-container, *ngIf, but never mind these, just look at the code structural difference (swapped
tr
withng-container
).Table head:
This produce the error:
Rearranging the code like below solves the error:
Check the count of your table column and dtColumnDefs. If you have 6 column then below will be your configuration for dtColumnDefs.