Ajax paging via server

Asked

Viewed 252 times

0

I need to make a pagination via server only via Ajax. Below I’m posting the grid how I’m doing, but I need to get the dynamic values and do not know how to do, follow the grid

function drawTable(habilita) {
dataTable = $('#tabFiltra').dataTable({
    "sPaginationType": "full_numbers",
    "bSearchable": false,
    "bDestroy": true,
    "bRetrieve": true,
    "bServerSide": true,
    "sAjaxSource": "query/getQuery",
    "aoColumns": [{ "bVisible": habilita }, null, null, null, null, null, null],
    "aLengthMenu": [[5, 10, 15, 25, 50, 100, 250], [5, 10, 15, 25, 50, 100, 250]],
    "iDisplayLength": 25,
    "oLanguage": {
        "sProcessing": "Processando...",
        "sLengthMenu": "Mostrar _MENU_ registros",
        "sZeroRecords": "Não foram encontrados resultados",
        "sInfo": "Mostrando de _START_ até _END_ de _TOTAL_ registros",
        "sInfoEmpty": "Mostrando de 0 até 0 de 0 registros",
        "sInfoFiltered": "(filtrado de _MAX_ registros no total)",
        "sInfoPostFix": "",
        "sSearch": "Buscar:",
        "sUrl": "",
        "oPaginate": {
            "sFirst": "«« Primeiro",
            "sPrevious": "« Anterior",
            "sNext": "Seguinte »",
            "sLast": "Último »»"
        }
    },
    "fnServerData": listaPassagensMes(1, 25, 9)

});

}

How do I get this value on the grid :

"iDisplayLength"

And even as I pass the others without failing the code ?

  • I don’t know if I got it wrong, but if the question is about function dataTable jQuery, I recommend including the tag [tag:jquery], to give better visibility and get organized.

  • 1

    Your question is unclear. You speak in AJAX without specifying if you can already fetch the information you need from the server. You can clarify?

1 answer

1


So what you can do is set a variable with values coming from an input, select and the like:

variavelValor = $('#idCampoAondeVemoValor').val();

"iDisplayLength": variavelValor,

As said is very practical to do and does not get "flunked" in the code

I hope I’ve helped

Browser other questions tagged

You are not signed in. Login or sign up in order to post.