Error message : oTable.rows is not a function

Error message : oTable.rows is not a function

shishi666shishi666 Posts: 4Questions: 2Answers: 0

Hello,
I want to use function rows() like in exemple on this site.
But i have an error message.
my javascript code for creat my dataTable :

$(document).ready(function() {
oTable = $('#pays').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"aaSorting": [[ 1, "asc" ]],
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [ 0 ] }
],
"sDom": '<"top"l<"clear">>rt<"bottom"p<"clear">>',
"aLengthMenu": [[25, 50, 100], [25, 50, 100]],
"iDisplayLength": 25,
"oLanguage": {
"sProcessing": "Traitement en cours...",
"sSearch": "Rechercher :",
"sLengthMenu": "Afficher MENU éléments",
"sInfo": "Affichage de l'élement START à END sur TOTAL éléments",
"sInfoEmpty": "Affichage de l'élement 0 à 0 sur 0 éléments",
"sInfoFiltered": "(filtré de MAX éléments au total)",
"sInfoPostFix": "",
"sLoadingRecords": "Chargement en cours...",
"sZeroRecords": "Aucun élément à afficher",
"sEmptyTable": "Aucun pays n'est disponible dans la base de donnée.",
"oPaginate": {
"sFirst": "Premier",
"sPrevious": "Précédent",
"sNext": "Suivant",
"sLast": "Dernier"
},
"oAria": {
"sSortAscending": ": activer pour trier la colonne par ordre croissant",
"sSortDescending": ": activer pour trier la colonne par ordre décroissant"
}
}
});
$('tbody').on( 'click', 'input[type=checkbox]', function () {
console.log( oTable.rows('.row_selected').length +' row(s) selected' );
} );
});

thanks a lot for your answer

Answers

  • DaimianDaimian Posts: 62Questions: 1Answers: 15

    To use the DataTables API you must access it correctly via one of the following ways:
    $( selector ).DataTable();
    $( selector ).dataTable().api();
    new $.fn.dataTable.Api( selector );

    Given your code I would simply change your oTable = $('#pays').dataTable to oTable = $('#pays').DataTable

This discussion has been closed.