How to jump to last page of pagination upon page load?
How to jump to last page of pagination upon page load?

Hi. I've been fiddling around this problem for the past 5 hours or so and cant seem to get this to work. is there any way we can go to the last page of pagination upon page load as i want the latest record to be shown below? im using dataTable version 1.10.19 by the way, been looking at different forums and sites for a solution. Below is my code snippet for calling the DataTable API::
var table = $('#item_history_table').DataTable({
ajax: base_url + 'item/get_item_history/1',
order: [],
paging: true,
ordering: false,
columns: [
{ data: 'date' },
{ data: 'customer' },
{ data: 'in' },
{ data: 'out' },
{ data: 'balance' }
]
});
This is what i've done already:
- tried using fnPageChange( 'last' ) but apparently, its already deprecated as of version 1.10
- tried using iDisplayStart but i dont know the last number of my record as its dynamic since i will add more record in the future so cant hard code the number
- tried using table.page('end').draw(false); but it doesn't work
- tried using table.page('end').draw('page'); but it also doesn't work
Any help is greatly appreciated! thanks in advance!
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
Answers
Two ways you can go:
order
to order by that date column so the most recent are at the top,initComplete
, something like this.Hope that helps,
Colin