row function not working while using .DataTable() to define table.
row function not working while using .DataTable() to define table.
Nixxer
Posts: 2Questions: 1Answers: 0
Hi following is my code, trying 2 get the .row() function working but it keeps returning the not a function error. I could not find any related problems.
$(document).ready(function () {
// Get the base table element.
const eventTable = $('#myTable');
// Initialize the datatable element.
eventTable.DataTable({
ajax: '../myjson.json',
paging: false,
info: false,
language: {
search: '',
searchPlaceholder: 'naam evenement',
},
columns: [
{ "data": "link" },
{ "data": "image" },
{ "data": "event" },
{ "data": "type" },
{ "data": "organiser" },
{ "data": "date" },
{ "data": "time" },
{ "data": "venue" },
{ "data": "city" },
],
columnDefs: [{
"targets": 0,
"visible": false,
"searchable": false,
"data": "link",
}]
});
// Attach the search filter to the filter section.
$('div.dataTables_filter').appendTo($('.filter'));
// Attach the click events.
eventTable.on('click', 'tr', function () {
let row = $(this);
if (row.hasClass('selected')) {
row.removeClass('selected');
}
else {
$('#myTable tr.selected').removeClass('selected');
row.addClass('selected');
let linkData = $('#myTable').row(row).data();
console.log(linkData);
}
});
});
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Yep, this
should be
Cheers,
Colin
Ah mate thanks! was looking too deep into it.
¡OMG!..... thanks for that answer so successful