console error "Cannot read property mData of undefined"..??

Hello, I am using jQuery datatable (little bit modified as in theme) in my project and getting error as below

Uncaught TypeError: Cannot read property 'mData' of undefined
    at HTMLTableCellElement.<anonymous> (jquery.dataTables.min.js:91)
    at Function.each (jquery-1.11.1.min.js:2)
    at m.fn.init.each (jquery-1.11.1.min.js:2)
    at HTMLTableElement.<anonymous> (jquery.dataTables.min.js:91)
    at Function.each (jquery-1.11.1.min.js:2)
    at m.fn.init.each (jquery-1.11.1.min.js:2)
    at m.fn.init.m [as dataTable] (jquery.dataTables.min.js:84)
    at HTMLDocument.<anonymous> (Details?CustomerProfileID=101088&pv=False:1316)
    at j (jquery-1.11.1.min.js:2)
    at Object.fireWith [as resolveWith] (jquery-1.11.1.min.js:2)

Here is my javascript code:

  var table = $('#dataTable');

        var settings = {
            "sDom": "<'table-responsive't><'row'<p i>>",
            "destroy": true,
            "autoWidth": false,
            "scrollCollapse": true,
            "oLanguage": {
                "sLengthMenu": "_MENU_ ",
                "sInfo": "Showing <b>_START_ to _END_</b> of _TOTAL_ entries"
           "iDisplayLength": 5 

it works on other pages/table but not working for one table, what can be the cause of the issue, not able to understand it, my table html looks proper with <tbody> & <thead> tags

Asked by:- pika
: 11449 At:- 1/2/2018 12:55:00 PM
jQuery jQuery-datatable Cannot read property mData of undefined

Check if number of columns are same in header and body, if your table has tbody and thead tag already then this could be the issue 0
By : vikas_jk - at :- 1/5/2018 10:17:37 AM

1 Answers
profileImage Answered by:- manish

These can be the possible issues related to this error :

1.Table must contain <thead> and <tbody> tags, otherwise it throws this error, for example below table will throw error

<table id="erroTable">

<!--Error may occur because of no tbody and thead defined-->

2. Mismatched number of columns(this table will also throw error) :

<table id="ErrorTable">
            <td>Error because of this extra value</td>

3.It can also occur if you have table arguments for 'aoColumns':[..] which don't match the correct number of columns, means may be you have defined aoColumns for 4 columns but there are only 2 columns in table.

4.Could occur due to Duplication of table Id(two table with same Ids)

At:- 1/2/2018 2:34:02 PM Updated at:- 2/13/2018 9:18:42 AM
My error was "2. Mismatched number of columns(this table will also throw error) ", thanks 0
By : pika - at :- 1/10/2018 8:31:28 AM
"Mismatched number of columns" solution, solved my error too, thanks. 0
By : jon - at :- 10/4/2018 1:40:44 PM

Login/Register to answer
Register directly by posting answer/details

Full Name *

Email *

By posting your answer you agree on privacy policy & terms of use

Subscribe Now

Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly