Need To Set Page From 'Page.Info' To '1' Not '0'

Need To Set Page From 'Page.Info' To '1' Not '0'

murday1983murday1983 Posts: 32Questions: 12Answers: 0
edited April 2019 in Free community support

I have a DataTable with the Paginator but when i use the following code

$('#reportDataTable').DataTable().page.info()

It says the page im on is '0' and not '1' when the table is loaded.

I need this to be 1 by default.

Am i missing something out here?

I have tried using the above code in

$('#reportDataTable').on( 'draw.dt', function () {
    console.log($('#reportDataTable').DataTable().page.info());
}

I have also tried:

    var info = $('#reportDataTable').DataTable().page.info();
    console.log('1 ' + info.page)
    var firstPage = info.page + 1;
    console.log('2 ' + firstPage)
    $('#reportDataTable').DataTable().page.info().page = firstPage;
    console.log($('#reportDataTable').DataTable().page.info().page)

which gives

But still comes as 0 and if i stick an alert in the above the alert is displayed before my table is displayed

Replies

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @murday1983 ,

    I'm not familiar with Paginator, but you could change the page with page() in initComplete.

    If that doesn't help, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.