Custom ajax function with pagination

Custom ajax function with pagination

alsantos123alsantos123 Posts: 2Questions: 0Answers: 0

Hello.

I use DataTable with a custom ajax function. Something like this:

DataTable({
    ajax: function(data, fnCallbackDataTable, settings)
    {
         var objAPI = new myCustomAPIClass();
         objAPI.list(param1, param2, function(list){
                fnCallbackDataTable( {data: list} );
         });
    }
})

(https://datatables.net/reference/option/ajax)

So far, so good, I get more than 20 rows and Datatables automatically create a second page. But when a user go to second page no ajax is executed, I don't know why.

The question is: How can I say to Datatables to execute my ajax function for each page? It is possible?

For now my ajax get all results at once, but this dataset will to be much bigger.

Cheers.

Replies

  • allanallan Posts: 63,791Questions: 1Answers: 10,513 Site admin

    You want DataTables to request more data from your function on every page? If so, that is called server-side processing in DataTables

    This manual page covers an overview of DataTables' data source options.

    Allan

  • alsantos123alsantos123 Posts: 2Questions: 0Answers: 0

    Nice, Allan.

    Thans for fast reply and for links.
    I will read and try implement.

    Cheers.

This discussion has been closed.