Pagination works only for some pages

Pagination works only for some pages

regisbsregisbs Posts: 4Questions: 3Answers: 0

Hope you could help me...

I have a datatable which the pagination works only ofr pages 1 to 5 and it contains 712 pages.. i can move between pages 1 to 5 but i cant access pages 6 to 721.

the lengthMenu also only work the two first options: 10, 25... the others 60 and 90 also doesn't work

this is my code

table.DataTable({
    scrollX: true,
    scrollCollapse: true,
    "order": [
        [0, "desc"]
    ],
    paging: true,
    "pagingType": "full_numbers",
    "serverSide": true,
    "ajax": {
        url: "views/tables/listAtendimentos2.php", // json datasource
        type: "post", // method  , by default get
        error: function() { // error handling
            $(".arquivos-error").html("");
            $("#arquivos").append('<tbody class="employee-grid-error"><tr><th colspan="3">No data found in the server</th></tr></tbody>');
            $("#arquivos_processing").css("display", "none");

        }
    },
    "language": {
        "sEmptyTable": "Nenhum registro encontrado",
        "sInfo": "Mostrando de _START_ até _END_ de _TOTAL_ registros",
        "sInfoEmpty": "Mostrando 0 até 0 de 0 registros",
        "sInfoFiltered": "(Filtrados de _MAX_ registros)",
        "sInfoPostFix": "",
        "sInfoThousands": ".",
        "sLengthMenu": "Mostar _MENU_ itens por página",
        "sLoadingRecords": "Carregando...",
        "sProcessing": "Processando...",
        "sZeroRecords": "Nenhum registro encontrado",
        "sSearch": "Pesquisar",
        "oPaginate": {
            "sNext": "Próximo <i class=\"fa fa-chevron-right\" aria-hidden=\"true\"></i>",
            "sPrevious": "<i class=\"fa fa-chevron-left\" aria-hidden=\"true\"></i> Anterior",
            "sFirst": "Primeiro",
            "sLast": "Último"
        },
        "oAria": {
            "sSortAscending": ": Ordenar colunas de forma ascendente",
            "sSortDescending": ": Ordenar colunas de forma descendente"
        }
    },
    "deferRender": true,
    "lengthChange": true,
    "lengthMenu": [
        [10, 25, 60, 90],
        [10, 25, 60, 90]
    ],
    "dom": 'lBfrtip',
    "buttons": [{
            extend: 'excel',
            title: 'Soares Nobre - Clientes',
            orientation: 'landscape'
        },
        {
            extend: 'pdf',
            title: 'Soares Nobre - Clientes',
            orientation: 'landscape'
        }
    ],
    "columns": [
        null,
        null,
        null,
        {
            "type": "date-eu"
        },
        null,
        null,
        null,
        null,
        null,
        null
    ],
    "initComplete": function() {
        var $buttons = $('.dt-buttons').hide();
        $("#pdf").on("click", function() {
            $('.buttons-pdf').click();
        });
        $("#excel").on("click", function() {
            $('.buttons-excel').click();
        });


        var ix = 0;
        this.api().columns().every(function() {
            var column = this;
            var select = $('<select id="coluna-' + ix + '"><option value=""></option></select>')
                .appendTo($(column.footer()).empty())
                .on('change', function() {
                    var val = $.fn.dataTable.util.escapeRegex(
                        $(this).val()
                    );

                    column
                        .search(val ? '^' + val + '$' : '', true, false)
                        .draw();
                });

            column.data().unique().sort().each(function(d, j) {
                select.append('<option value="' + d + '">' + d + '</option>');
                if (ix == 1) {
                    $("#cliente").append('<option value="' + d + '" data-valor="' + d + '">' + d + '</option>');
                }
                if (ix == 2) {
                    $("#imovel").append('<option value="' + d + '" data-valor="' + d + '">' + d + '</option>');
                }
                if (ix == 4) {
                    $("#atendimento").append('<option value="' + d + '" data-valor="' + d + '">' + d + '</option>');
                }
                if (ix == 5) {
                    $("#origem").append('<option value="' + d + '" data-valor="' + d + '">' + d + '</option>');
                }
                if (ix == 6) {
                    $("#status").append('<option value="' + d + '" data-valor="' + d + '">' + d + '</option>');
                }
                if (ix == 7) {
                    $("#temperatura").append('<option value="' + d + '" data-valor="' + d + '">' + d + '</option>');
                }
                if (ix == 8) {
                    $("#corretor").append('<option value="' + d + '" data-valor="' + d + '">' + d + '</option>');
                }
                if (ix == 9) {
                    $("#criado").append('<option value="' + d + '" data-valor="' + d + '">' + d + '</option>');
                }

            });
            ix++;
        });

    }
});


};

return {

    //main function to initiate the module
    init: function() {
        initTable1();
    }
};
}();

Answers

  • kthorngrenkthorngren Posts: 21,260Questions: 26Answers: 4,932

    Start by debugging your server side script to see why pages 1 through 5 and length options 10 and 25 only work. Your server side script is responsible for fetching and returning the rows for the selected page.

    Kevin

This discussion has been closed.