Can We implement dynamic pagination on Client Side?

Can We implement dynamic pagination on Client Side?

viksnanuviksnanu Posts: 7Questions: 5Answers: 0

I have datatable implemented on my page. I am getting whole data using ajax call in one time as json and then displaying it on datatable. What I need here is, I want a dropdown which can change the number of records to be shown on my page and change the pagination accordingly. But i don't want to get the data on every change. I have whole data in one time, but i just want to change view dynamically. Can it be done in anyway here in datatable? Please help me with this.

Answers

  • MSLtdMSLtd Posts: 56Questions: 5Answers: 4

    Hi @viksnanu it seems what you're looking for can be found here: DOM.
    In your JavaScript where you initialise the table the dom attribute should be assigned something like Blfrtip rather than Bfrtip - if you've pasted from examples, a lot of them don't include this.

    You may also need to add the attribute "lengthChange": true in the initialisation.

    e.g.

    table = $('#line_items').DataTable( {
        dom: 'Blfrtip',
        "lengthChange": true
        //...ajax, columns and other attributes here.
    });
    

    Shout if you need any more help! :smile:

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    The pagination control should automatically update for any changes in the page length options. That can be seen in this example.

    Allan

  • viksnanuviksnanu Posts: 7Questions: 5Answers: 0

    Can we apply spinner to the same in anyway?

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    What spinner?

This discussion has been closed.