datatable server side pagination doesn't work

datatable server side pagination doesn't work

lishulishu Posts: 6Questions: 2Answers: 0

Even returning this:

"recordsTotal": 17,
"recordsFiltered": 10,

the datatable, show only one page in the paginator section.

Does somebody try this in the new versión?

here you can see my problem:
http://i58.tinypic.com/miz9kz.jpg

This question has an accepted answers - jump to answer

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395
    Answer ✓

    Perhaps your server-side script only requests 10 records, but as you don't provide any code I can't say.

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin

    "recordsTotal": 17, "recordsFiltered": 10,

    You are telling it there are only 10 records int he filtered results, so assuming your page length is the default of 10, then it is correct, there is only 1 page.

    Might be worth re-reading the documentation:

    Total records, after filtering (i.e. the total number of records after filtering has been applied - not just the number of records being returned for this page of data).

    Allan

  • lishulishu Posts: 6Questions: 2Answers: 0

    ok thanks Allan.
    and tell me how to say:
    Total records: 1.000
    Total records with this filter 200
    total records to show: 10..

    tell me if i am wrong, but the idea of server side is not bring all database to client side, just necesarry records.
    so if i said that i am showing 10 records, and total records are 1000, the pagination should do the pagination based on the total records..
    or i am wrong?
    Thanks regards.

  • lishulishu Posts: 6Questions: 2Answers: 0

    Thanks tangerine for your reply.

    The documentation define which fields should return.
    But, there is no example of pagination.
    because all the example always return 57 records as total.

    This is my entire code:
    as you can see, the total records in DB are 13 but i just want to return 10.

    { "draw":1,
    "recordsTotal": 13,
    "recordsFiltered": 10,
    "data":[{"DT_RowId": "fila_22", "0":22, "1":"Hospital de Claudio2", "2":"<a href='javascript:Editar(22)'><span class='glyphicon glyphicon-pencil' title='Editar'></span></a><a href='javascript:mostrarEliminar(22)'><span class='glyphicon glyphicon-remove' title='Eliminar'></span></a>"},{"DT_RowId": "fila_20", "0":20, "1":"cree uno nuevo", "2":"<a href='javascript:Editar(20)'><span class='glyphicon glyphicon-pencil' title='Editar'></span></a><a href='javascript:mostrarEliminar(20)'><span class='glyphicon glyphicon-remove' title='Eliminar'></span></a>"},{"DT_RowId": "fila_16", "0":16, "1":"asd", "2":"<a href='javascript:Editar(16)'><span class='glyphicon glyphicon-pencil' title='Editar'></span></a><a href='javascript:mostrarEliminar(16)'><span class='glyphicon glyphicon-remove' title='Eliminar'></span></a>"},{"DT_RowId": "fila_15", "0":15, "1":"aqwe ", "2":"<a href='javascript:Editar(15)'><span class='glyphicon glyphicon-pencil' title='Editar'></span></a><a href='javascript:mostrarEliminar(15)'><span class='glyphicon glyphicon-remove' title='Eliminar'></span></a>"},{"DT_RowId": "fila_14", "0":14, "1":"gh", "2":"<a href='javascript:Editar(14)'><span class='glyphicon glyphicon-pencil' title='Editar'></span></a><a href='javascript:mostrarEliminar(14)'><span class='glyphicon glyphicon-remove' title='Eliminar'></span></a>"},{"DT_RowId": "fila_13", "0":13, "1":"gh", "2":"<a href='javascript:Editar(13)'><span class='glyphicon glyphicon-pencil' title='Editar'></span></a><a href='javascript:mostrarEliminar(13)'><span class='glyphicon glyphicon-remove' title='Eliminar'></span></a>"},{"DT_RowId": "fila_12", "0":12, "1":"asdqwe", "2":"<a href='javascript:Editar(12)'><span class='glyphicon glyphicon-pencil' title='Editar'></span></a><a href='javascript:mostrarEliminar(12)'><span class='glyphicon glyphicon-remove' title='Eliminar'></span></a>"},{"DT_RowId": "fila_10", "0":10, "1":"asd", "2":"<a href='javascript:Editar(10)'><span class='glyphicon glyphicon-pencil' title='Editar'></span></a><a href='javascript:mostrarEliminar(10)'><span class='glyphicon glyphicon-remove' title='Eliminar'></span></a>"},{"DT_RowId": "fila_7", "0":7, "1":"sssswwwww77", "2":"<a href='javascript:Editar(7)'><span class='glyphicon glyphicon-pencil' title='Editar'></span></a><a href='javascript:mostrarEliminar(7)'><span class='glyphicon glyphicon-remove' title='Eliminar'></span></a>"},{"DT_RowId": "fila_4", "0":4, "1":"lishu", "2":"<a href='javascript:Editar(4)'><span class='glyphicon glyphicon-pencil' title='Editar'></span></a><a href='javascript:mostrarEliminar(4)'><span class='glyphicon glyphicon-remove' title='Eliminar'></span></a>"}]}

  • lishulishu Posts: 6Questions: 2Answers: 0

    Thanks tangerine for your reply.

    The documentation define which fields should return.
    But, there is no example of pagination.
    because all the example always return 57 records as total.

    This is my entire code:
    as you can see, the total records in DB are 13 but i just want to return 10.

    { "draw":1,
    "recordsTotal": 13,
    "recordsFiltered": 10,
    "data":[{"DT_RowId": "fila_22", "0":22, "1":"Hospital de Claudio2", "2":"<a href='javascript:Editar(22)'><span class='glyphicon glyphicon-pencil' title='Editar'></span></a><a href='javascript:mostrarEliminar(22)'><span class='glyphicon glyphicon-remove' title='Eliminar'></span></a>"},{"DT_RowId": "fila_20", "0":20, "1":"cree uno nuevo", "2":"<a href='javascript:Editar(20)'><span class='glyphicon glyphicon-pencil' title='Editar'></span></a><a href='javascript:mostrarEliminar(20)'><span class='glyphicon glyphicon-remove' title='Eliminar'></span></a>"},{"DT_RowId": "fila_16", "0":16, "1":"asd", "2":"<a href='javascript:Editar(16)'><span class='glyphicon glyphicon-pencil' title='Editar'></span></a><a href='javascript:mostrarEliminar(16)'><span class='glyphicon glyphicon-remove' title='Eliminar'></span></a>"},{"DT_RowId": "fila_15", "0":15, "1":"aqwe ", "2":"<a href='javascript:Editar(15)'><span class='glyphicon glyphicon-pencil' title='Editar'></span></a><a href='javascript:mostrarEliminar(15)'><span class='glyphicon glyphicon-remove' title='Eliminar'></span></a>"},{"DT_RowId": "fila_14", "0":14, "1":"gh", "2":"<a href='javascript:Editar(14)'><span class='glyphicon glyphicon-pencil' title='Editar'></span></a><a href='javascript:mostrarEliminar(14)'><span class='glyphicon glyphicon-remove' title='Eliminar'></span></a>"},{"DT_RowId": "fila_13", "0":13, "1":"gh", "2":"<a href='javascript:Editar(13)'><span class='glyphicon glyphicon-pencil' title='Editar'></span></a><a href='javascript:mostrarEliminar(13)'><span class='glyphicon glyphicon-remove' title='Eliminar'></span></a>"},{"DT_RowId": "fila_12", "0":12, "1":"asdqwe", "2":"<a href='javascript:Editar(12)'><span class='glyphicon glyphicon-pencil' title='Editar'></span></a><a href='javascript:mostrarEliminar(12)'><span class='glyphicon glyphicon-remove' title='Eliminar'></span></a>"},{"DT_RowId": "fila_10", "0":10, "1":"asd", "2":"<a href='javascript:Editar(10)'><span class='glyphicon glyphicon-pencil' title='Editar'></span></a><a href='javascript:mostrarEliminar(10)'><span class='glyphicon glyphicon-remove' title='Eliminar'></span></a>"},{"DT_RowId": "fila_7", "0":7, "1":"sssswwwww77", "2":"<a href='javascript:Editar(7)'><span class='glyphicon glyphicon-pencil' title='Editar'></span></a><a href='javascript:mostrarEliminar(7)'><span class='glyphicon glyphicon-remove' title='Eliminar'></span></a>"},{"DT_RowId": "fila_4", "0":4, "1":"lishu", "2":"<a href='javascript:Editar(4)'><span class='glyphicon glyphicon-pencil' title='Editar'></span></a><a href='javascript:mostrarEliminar(4)'><span class='glyphicon glyphicon-remove' title='Eliminar'></span></a>"}]}

This discussion has been closed.