- TypeError: $(…).DataTable is not a function
- TypeError: aData is undefined
- TypeError: f is undefined
- TypeError: Cannot read property ‘length’ of undefined
- TypeError: headerCells[i] is undefined
- TypeError: n[m] is undefined
- TypeError: Cannot read property ‘style’ of undefined
- TypeError: Cannot set property ‘nTf’ of undefined
- TypeError: Cannot read property ‘mData’ of undefined
- TypeError: col is undefined
TypeError: $(…).DataTable is not a function
Cause
- jQuery DataTables library is missing.
- jQuery library is loaded after jQuery DataTables.
- Multiple versions of jQuery library is loaded.
Solution
Include only one version of jQuery library version 1.7 or newer before jQuery DataTables.
TypeError: aData is undefined
Cause
jQuery DataTables cannot find the data in the response to the Ajax request.
By default jQuery DataTables expects the data to be in one of the formats shown below. Error occurs because data is returned in the format other than default.
{ "data": [ [ "Tiger Nixon", "System Architect", "$320,800", "2011/04/25", "Edinburgh", "5421" ] ] }
{ "data": [ { "name": "Tiger Nixon", "position": "System Architect", "salary": "$320,800", "start_date": "2011/04/25", "office": "Edinburgh", "extn": "5421" } ] }
Solution
Use default format or use ajax.dataSrc option to define data property containing table data in Ajax response (data
by default).
See Data array location for more information.
TypeError: f is undefined
See the following errors for a possible cause and solution:
TypeError: Cannot read property ‘length’ of undefined
See the following errors for a possible cause and solution:
TypeError: headerCells[i] is undefined
TypeError: n[m] is undefined
Cause
- Number of
th
elements in the table header or footer differs from number of columns in the table body or defined using columns option. - Attribute
colspan
is used forth
element in the table header. - Incorrect column index specified in columnDefs.targets option.
Solution
- Make sure that number of
th
elements in the table header or footer matches number of columns defined in the columns option. - If you use
colspan
attribute in the table header, make sure you have at least two header rows and one uniqueth
element for each column. See Complex header for more information. - If you use columnDefs.targets option, make sure that zero-based column index refers to existing columns.
TypeError: Cannot read property ‘style’ of undefined
See the following errors for a possible cause and solution:
TypeError: Cannot set property ‘nTf’ of undefined
Cause
- Number of
th
elements in the table footer differs from number ofth
elements in the table header.
Solution
- Make sure that number of
th
elements in the table footer matches number ofth
elements in the table header.
TypeError: Cannot read property ‘mData’ of undefined
TypeError: col is undefined
Cause
- Missing table header.
- Number of
td
elements in the table body differs from number ofth
elements in the table header.
Solution
- Make sure that your table has a header. See Requirements for more information.
- Make sure that number of
td
elements in the table footer matches number ofth
elements in the table header.
thanks, very useful. solved TypeError: $(…).DataTable is not a function error for me. I spent hours looking for the reason. then your concise comment (loading more than one jquery library) solved it. I was loading two versions in two different places in my html. thanks,
Thank you, Mohamed!
I got this error.TypeError: aLayout[i][j] is undefined.
Please Help me to solve this issue. And another error which i faced while generating pdf that was colspan in pdf. I can’t set colspan and rowspan in export pdf using datatables.
@Michael Ryvkin sir Please Guide me. I am waiting for your reply.
DataTables only support
colspan
androwspan
attributes if there is at least oneTH
cell which is unique to the column, please see this example. I suspect you get this error because you don’t have one uniqueTH
per column. If you could create an example on jsFiddle demonstrating your problem or share your HTML markup, I would be able to provide more specific response.Michael Ryvkin Sir, Thank you for your guidance. But the problem was that when I tried to generate a PDF in that case rowspan and colspan is not working. Sir please see this example http://jsfiddle.net/genxcoders/kpbsn812/29/. Sir, I am waiting for your guidance. Thank you !
Michael Ryvkin sir. In this code i got this error.TypeError: aLayout[i][j] is undefined. https://jsfiddle.net/Kalyani_Genxcoders/6apjy28w/8/ . I want to export this table in Excel and PDF using datatables. Please Guide me. Thank you In advance.
Thanks a lot. I resolved “col is undefined” error.
TypeError: widths[i] is undefined.
@Michael Ryvkin sir Please Guide me. I got this error while exporting the pdf. Thanks in advance.
You litteraly saved my life!!! thanksssss <3
hello, i have this error:
vista.php:152 Uncaught TypeError: Cannot read property ‘id’ of undefined
i dont find the solution 🙁
As i was rendering columns dynamically, some rows <td> were not matching total columns and hence it was showing error.
Uhfff work for me!!!