How to use pagination with server-side data loaded via Javascript ?

How to use pagination with server-side data loaded via Javascript ?

nbougetnbouget Posts: 3Questions: 2Answers: 0

Hello,

I'm experimenting several JS libraries about dynamic tables with sorting/filtering/ordering etc.
I can see that DataTables support several data sources: Ajax, HTML, Javascript or even Server-Side processing.

It seems that only the Server-Side processing provides a way to load only a part of the data (a page) on the browser and still keeping the pagination displayed well.

Problem is, I don't want DataTables to have an URL to call, I want to retrieve the data myself and then set it.

I was wondering if I could load a page via Javascript and then somehow give all the information about the paging to DataTables (number total of elements, current page etc.) so it can display the pagination ?

Regards,
Nicolas Bouget

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    http://datatables.net/examples/data_sources/js_array.html

    The example shows Javascript-sourced data and pagination, although I'm not entirely sure what you actually want.

  • nbougetnbouget Posts: 3Questions: 2Answers: 0

    First, thanks for the quick answer.

    I checked this example but there are 2 problems I want to solve from it:
    - I need to set new values after initialization, is it possible ? I handle my Ajax calls in a specific module and I would like to not mix it into my other modules.
    - I want to paginate on the server side and it seems that setting the data via javascript will do only client side pagination

This discussion has been closed.