I'm trying to set up an extremely basic DataTables example. After initializing the table with DataTables, why are some of the API methods not available? Am I missing something as far as how it's supposed to be used?
Here's a simple jsfiddle where I initialize the table, and then try to retrieve the first row. However, it doesn't look the like row()
method exists:
/
Here's the javascript in the fiddle:
$(document).ready(function(){
var myDataTable = $('#myTable').dataTable();
console.log(myDataTable.row(0));
});
Developer console shows the following error referring to the console.log
line:
Uncaught TypeError: undefined is not a function
Any help here is much appreciated.
I'm trying to set up an extremely basic DataTables example. After initializing the table with DataTables, why are some of the API methods not available? Am I missing something as far as how it's supposed to be used?
Here's a simple jsfiddle where I initialize the table, and then try to retrieve the first row. However, it doesn't look the like row()
method exists:
http://jsfiddle/LEWQU/
Here's the javascript in the fiddle:
$(document).ready(function(){
var myDataTable = $('#myTable').dataTable();
console.log(myDataTable.row(0));
});
Developer console shows the following error referring to the console.log
line:
Uncaught TypeError: undefined is not a function
Any help here is much appreciated.
Share Improve this question edited Jun 17, 2014 at 23:57 flyingL123 asked Jun 17, 2014 at 22:34 flyingL123flyingL123 8,13613 gold badges74 silver badges138 bronze badges 3- Authorization required to load the jquery.dataTables.min.js and the jquery-2.0.3.min.js files. – bloodyKnuckles Commented Jun 17, 2014 at 22:44
- Sorry about that @bloodyKnuckles, it's all fixed now. – flyingL123 Commented Jun 17, 2014 at 23:32
-
For this simple example, this is pulling up the rows:
myDataTable[0].rows
, and cells can be got:myDataTable[0].rows[0].cells
. – bloodyKnuckles Commented Jun 18, 2014 at 0:28
3 Answers
Reset to default 3change
var myDataTable = $('#myTable').dataTable();
to
var myDataTable = $('#myTable').DataTable();
Couple of things:
authorization is required to load jquery datatables (as bloodyknuckles pointed out too)
the method is "dataTable()" and not "DataTable()"
Still not really sure what the issue was, but updating to the newest version of DataTables seems to have worked.