Saltar al contenido

mostrar todos los registros en la tabla de tablas de datos cuando haga clic en el botón

Este escrito fue analizado por nuestros expertos así se garantiza la exactitud de este enunciado.

Solución:

dataTables proporcionar varias funciones para lograr esto. Así que a continuación se muestra la forma en que puede hacer esto. Consulte los comentarios en línea para obtener más información:

MANIFESTACIÓN

var oTable; //global variable to hold reference to dataTables
var oSettings; //global variable to hold reference to dataTables settings

$(document).ready(function()
    oTable=$('#sample_table').DataTable( 
        "bSort": false,
        "pagingType": "full_numbers",
        "dom": 'T<"clear">lfrtip',
    ); //store reference of your table in oTable
    oSettings = oTable.settings(); //store its settings in oSettings
);

$("#show_all_records").on('click',function()
   oSettings[0]._iDisplayLength = oSettings[0].fnRecordsTotal();
   //set display length of dataTables settings to the total records available
   oTable.draw();  //draw the table
);

$("#restore_records").on('click',function()
    oSettings[0]._iDisplayLength=10;
   //set it back to 10
    oTable.draw();//again draw the table
);

puedes usar "lengthMenu" dar opción en show entitiesdrop down para mostrar todos los registros. no necesitas show all records y Restore records on its default state botones (en este caso).

$('#sample_table').DataTable(
    "bSort": false,
        "pagingType": "full_numbers",
        "dom": 'T<"clear">lfrtip',
        "lengthMenu": [[10, 25, 50, -1],[10, 25, 50, "All"]
    ]
);




Name Position Branch Department
Sample Name 1 Sample position sample branch sample department
Sample Name 2 Sample position sample branch sample department
Sample Name 3 Sample position sample branch sample department
Sample Name 4 Sample position sample branch sample department
Sample Name 5 Sample position sample branch sample department
Sample Name 6 Sample position sample branch sample department
Sample Name 7 Sample position sample branch sample department
Sample Name 8 Sample position sample branch sample department
Sample Name 9 Sample position sample branch sample department
Sample Name 10 Sample position sample branch sample department
Sample Name 11 Sample position sample branch sample department
Sample Name 12 Sample position sample branch sample department
Sample Name 13 Sample position sample branch sample department
Sample Name 14 Sample position sample branch sample department
Sample Name 15 Sample position sample branch sample department
Sample Name 16 Sample position sample branch sample department
Sample Name 17 Sample position sample branch sample department
Sample Name 18 Sample position sample branch sample department
Sample Name 19 Sample position sample branch sample department
Sample Name 20 Sample position sample branch sample department
Sample Name 21 Sample position sample branch sample department
Sample Name 22 Sample position sample branch sample department
Sample Name 23 Sample position sample branch sample department
Sample Name 24 Sample position sample branch sample department
Sample Name 25 Sample position sample branch sample department
Sample Name 26 Sample position sample branch sample department
Sample Name 27 Sample position sample branch sample department
Sample Name 28 Sample position sample branch sample department
Sample Name 29 Sample position sample branch sample department
Sample Name 30 Sample position sample branch sample department
Sample Name 31 Sample position sample branch sample department
Sample Name 32 Sample position sample branch sample department
Sample Name 33 Sample position sample branch sample department
Sample Name 34 Sample position sample branch sample department
Sample Name 35 Sample position sample branch sample department
Sample Name 36 Sample position sample branch sample department
Sample Name 37 Sample position sample branch sample department
Sample Name 38 Sample position sample branch sample department
Sample Name 39 Sample position sample branch sample department
Sample Name 40 Sample position sample branch sample department

No se te olvide comunicar este artículo si te ayudó.

¡Haz clic para puntuar esta entrada!
(Votos: 1 Promedio: 3)



Utiliza Nuestro Buscador

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *