2012-02-25 16 views

risposta

163

Usa:

$('#example').dataTable({ 
    aLengthMenu: [ 
     [25, 50, 100, 200, -1], 
     [25, 50, 100, 200, "All"] 
    ], 
    iDisplayLength: -1 
}); 

O se utilizza 1.10+

$('#example').dataTable({ 
    paging: false 
}); 
+14

Oppure "paging": false' se si utilizza [DataTables 1.10 nuova API] (https://datatables.net/reference/option/paging). –

+0

Oppure '

' se si desidera utilizzare le opzioni DOM (DataTables 1.10+, vedere https://datatables.net/manual/data/orthogonal-data#HTML-5) . –

+2

La carne di questa risposta molto corretta è iDisplayLength: -1 –

0

uso 'fnDrawCallback'

$('#dataTable').dataTable({ 
     "bJQueryUI": true, 
     "sPaginationType": "full_numbers", 
     "fnInitComplete": function(){ 
      $('.display_results').show(); 
     }, 
     "fnDrawCallback": function() { 
      $('.def').click(function(){ 
       var msg = $(this).next().text(); 
       $('.messages').messageBox()//Custom Dialog 
      }); 
     } 
}) 
12

L'opzione si dovrebbe usare è iDisplayLength:

$('#adminProducts').dataTable({ 
    'iDisplayLength': 100 
}); 
3
$('#table').DataTable({ 
    "lengthMenu": [ [5, 10, 25, 50, -1], [5, 10, 25, 50, "All"] ] 
}); 
+0

funziona con questa tabella: https://datatables.net/examples/api/form.html –

0

Se stai usando DataTable 1.10+ è possibile utilizzare l'dati- * attributo nel tag <table>data-page-length="-1"

Questo presuppone che "-1" definito nella configurazione di default DataTable, come ad come di seguito

$.extend(true, $.fn.dataTable.defaults, { 
    lengthMenu: [[10, 25, 50, 250, -1], [10, 25, 50, 250, "All"]] 
}); 

Javascript diventa semplicemente $("table").DataTables(); e siete in grado di personalizzare la visualizzazione per ogni tabella all'interno del codice HTML; IE. se si dispone secondo, tavolo più piccolo nella stessa pagina che dovrebbe essere limitato a 10 righe, <table data-page-length="10">

1

Questo funziona per me:

$(document).ready(function() { 
    $('#example').DataTable({ 
     "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]] 
     }); 
    }); 
0

Ecco l'intero javascript funzionale per il file .html

<!--- javascript --> 
<script type="text/javascript"> 
    $(document).ready(function(){ 
    $('#sortable').dataTable({ 
     'iDisplayLength': 100 
    })}) 
</script> 
Problemi correlati