Since: DataTables 1.10

Get / set the table's page length.


This method is used quite simply to get and set the length of the paging used by DataTables for display. Please note that this is only relevant when paging is enabled in the table.

The special number -1 can be used as a set parameter, and returned by the get format of this function to indicate that all rows in the DataTable will be displayed.

Please be aware that this method sets the page to be shown - it does not actually perform the re-display of the table. In order to have the newly set page shown use the draw() method, which can be called simply as a chained method of the page() method's returned object - for example 0 ).draw();.


function page.len()


Get the page length of the table. Note that if multiple tables are available in the API's context, the page length of the first table in the context will be used. Use table() if you are working with multiple tables in a single API context.


Current page length. Note that -1 indicates that all records are shown.

function page.len( set )


Set the page length to be used for the display


DataTables API instance


Allow user to click on two elements to select if all records should be shown or just 10.:

var table = $('#example').DataTable();

$('#all').on( 'click', function () { -1 ).draw();
} );

$('#_10').on( 'click', function () { 10 ).draw();
} );


The following options are directly related and may also be useful in your application development.