Question regarding server side processing

Question regarding server side processing

mikeshawmikeshaw Posts: 3Questions: 1Answers: 0

We are using server side processing with Ajax data source.
When the datatable is initially loaded the Page Numbers and Showing xxx to xx of xxx is fine. If the user is on the last page of a large dataset and then changes the filtering of the data via a change in the selection of a drop down list on the page, I am able to force back to page number one but the Shownig xxx to xxx of xxx is incorrect and page number one is not highlighted.
Is there a way to address this. See below code where data,Count is the records total and PageNo is the start parameter sent from the Ajax call.

if (data.Count < PageNo)
{
dtp.draw = 2;
dtp.start = 0;
PageNo = dtp.start;
}

        data = data.Skip(PageNo).Take(pageSize).ToList();

Looking at the documentation for datatables there does not appear to be a way to reliably force the draw of the datatable back to page one with correct button highlighted and Showing info being correct.

This question has an accepted answers - jump to answer

Answers

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

    Hi @mikeshaw ,

    You can reset the page using page() - you could call this in the click event for your dropdown selection.

    Cheers,

    Colin

  • mikeshawmikeshaw Posts: 3Questions: 1Answers: 0

    When I try this:
    var table = $("#tblWfloTasksQueue").dataTable();
    table.page(0);

    I get error 0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'page'

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

    Try,

    var table = $("#tblWfloTasksQueue").DataTable();
    table.page(0);
    

    note the capitalisation of DataTable()

  • mikeshawmikeshaw Posts: 3Questions: 1Answers: 0

    Thanks Colin for your help on this!! You're a life saver!

This discussion has been closed.