I have following code that is using data table
Contact.dataTable = $('#table').dataTable( {
.............
},
$('#table tbody').on('click', '.position', function () {
var row = this.parentElement;
var data = Contact.dataTable.row(row).data();
...
}
Since above code was giving error "TypeError: Contact.dataTable.row is not a function"
, I have changed every dataTable
to DataTable
. But now it gives error "TypeError: Contact.DataTable.fnDestroy is not a function"
.
Below is the code that gives error
Contact.DataTable = $('#table').DataTable( {
.............
},
$('#table tbody').on('click', '.position', function () {
var row = this.parentElement;
var data = Contact.DataTable.row(row).data();
...
}
if('DataTable' in Contact) {
Contact.DataTable.fnDestroy();
}
Anyone please help!
I have following code that is using data table
Contact.dataTable = $('#table').dataTable( {
.............
},
$('#table tbody').on('click', '.position', function () {
var row = this.parentElement;
var data = Contact.dataTable.row(row).data();
...
}
Since above code was giving error "TypeError: Contact.dataTable.row is not a function"
, I have changed every dataTable
to DataTable
. But now it gives error "TypeError: Contact.DataTable.fnDestroy is not a function"
.
Below is the code that gives error
Contact.DataTable = $('#table').DataTable( {
.............
},
$('#table tbody').on('click', '.position', function () {
var row = this.parentElement;
var data = Contact.DataTable.row(row).data();
...
}
if('DataTable' in Contact) {
Contact.DataTable.fnDestroy();
}
Anyone please help!
Share Improve this question edited Aug 10, 2015 at 5:28 Futuregeek asked Aug 9, 2015 at 16:13 FuturegeekFuturegeek 1,9803 gold badges30 silver badges52 bronze badges 2-
Uhm,
Contact.dataTable !== Contact.DataTable
, you seem to still be working with two different things ? – adeneo Commented Aug 9, 2015 at 16:16 - No, when I use Contact.dataTable -> it gives me error like Contact.dataTable.row is not a function. So I replaced every instances of dataTable with DataTable - and it now gives error - fnDestroy is not a function – Futuregeek Commented Aug 9, 2015 at 16:32
3 Answers
Reset to default 5It seems to be the difference between...
_table = jQuery('table#fp-table-table').dataTable(); // .fnDestroy() works and
_table = jQuery('table#fp-table-table').DataTable(); // .fnDestroy() doesn't work DataTable seems to be for API calls back into the object and dataTable seems to be the intialisation method.
In my project I had changed the initialisation to use DataTable instead of dataTable to perform a filtering task. After this my AJAX reloads would throw the 'undefined' error, so I changed it back... i esta.
See this thread here - it talks about the difference between .DataTable()
and .dataTable()
.
Declare var Contact = $('#table').DataTable
at the top and then use it Like Contact.fnDestroy()
It worked For me so give it try