All,
I am using Jquery Data Tables. I am using the following example:
DataTables with Pagination
I was wondering if there's a way to display "Show 10 Entries" on the bottom instead of top. It should be displayed right before "Showing 1 to 10 of 51 entries".. at the bottom of the table.
How can I do that?
Thanks
The pageLength option is used to specify the number of rows of the table that are to be displayed on one page. This option is relevant when the pagination is used to display many rows. It accepts an integer value that denotes the number of rows to be displayed.
The lengthChange option is used to specify whether the dropdown to change the number of rows per page is displayed or not. This dropdown is shown only when paging of the DataTable is enabled, as disabling it automatically removes the dropdown. A true value displays the dropdown and a false value removes it.
There is a option called pageLength . You can set this for show only 5 entries.
pagelength statement controls where page breaks occur. The report formatter subtracts the number of lines in the footer (specified in the . footer page section of the specifications) from the total page length of nlines. Page length is the total number of body text lines for the page.
The way to do that is to change the sDom in the .js, where you define the table:
$('#TABLE_ID').dataTable({`
"sDom": 'Rfrtlip'`
});
Additionally, you should change the .css to appear next to the "Showing ... entries", because this way it appear above it.
This is the explanation of the sDom options:
The following options are allowed:
The following constants are allowed:
The following syntax is expected:
PS: This could also help you:
datatables sDom
add-datatables-length-at-the-bottom-of-the-table
Had a similar problem (wanted to remove some unnecessary controls) and the only way to deal with it seems to be modifying table yourself. I used fnDrawCallback callback (http://datatables.net/usage/callbacks).
It will be something like this in your case
$('#tableId').dataTable({
"fnDrawCallback": function () {
$('#tableId_info').prepend($('#tableId_length'));
}
});
Just check the generated code in that demo, it's really quite simple (except it has no formatting or indentation).
You can also use class names instead of ids, if you're not afraid to affect other tables on the page. They're in the form dataTables_length
.
Use css for additional styling.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With