Show all rows not working
Show all rows not working
E_Brandao
Posts: 12Questions: 5Answers: 0
My database has 1545 rows, when i define the page lenght as -1, i get teh following error "DataTables warning: table id=DataTables_Table_1 - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1", but when i put 1545 in the page lenght, it works.
$(document).ready(function(){
$('.table-log-notas').DataTable({
"serverSide": true,
"ajax": {
"url": "../assets/php/functions/tabela-notas.php",
"type": "POST"
},
responsive: true,
"pageLength": -1,
dom: 'Bfrtip',
lengthMenu: [
[ 10, 50, 100, 1000 ],
[ '10 linhas', '50 linhas', '100 linhas', 'todas as linhas' ]
],
buttons: [
'excel', 'pdf','pageLength'
],
//Definição dos textos que aparecerão na tabela
"language": {
"lengthMenu": "Mostrando _MENU_ registros por página",
"zeroRecords": "Nada encontrado",
"info": "Mostrando página _PAGE_ de _PAGES_",
"infoEmpty": "Nenhum registro disponível",
"infoFiltered": "(filtrado de _MAX_ registros no total)",
"sSearch": "Pesquisar",
"oPaginate": {
"sNext": "Próximo",
"sPrevious": "Anterior",
"sFirst": "Primeiro",
"sLast": "Último"
},
buttons: {
pageLength: {
_: "Mostrando %d linhas"
}
}
},
scrollY: 200,
scroller: {
loadingIndicator: true
},
});
});
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
The -1 option applies to lengthMenu, not pageLength.
When you use
"pageLength": -1,
with server side processing thelength
parameter sent to the server will be-1
. Does you server script handle this properly?Kevin
Should mention that using
"pageLength": -1,
you should disable server side processing as it is not helping reduce the number of rows. In fact it will cause a request to the server for each search and sort instead of just using the client for these functions.Kevin
Thanks, was a problem in server side script, it was not handling this properly.
To fix, i wrote in the server side script:
Obs.: the variable $qnt_linhas is the number of rows of the query