genarate pagination numbers based on total records

genarate pagination numbers based on total records

catchcatch Posts: 4Questions: 1Answers: 0
edited December 2020 in Free community support

1) I am new for data tables, my stored procedure returns 10 records per page,
I am trying to generate pagination number based on total records(if record are 40 it
should show 1,2,3,4 but I retrieve only 10 records),
for ex : when I click on pageno:2,
again ajax call should happen and return next 10 rows.
2) How to pass the total record count to datatable property in ajax call
how can I achieve this. is it possible.
Please help me.

Answers

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

    It sounds like you want to enable server side processing with serverSide. The protocol is discussed here. Also see examples here.

    Otherwise, you'll need to give the table all the datam rather than just sections.

    If you've only a few thousand records, just send the table everything, it'll be more efficient that way.

    Cheers,

    Colin

  • yericusyericus Posts: 20Questions: 4Answers: 1

    Not sure what you mean there, I think you might need to reformulate your question.

    Datatables already generates pagination automatically and has some easily accessible options the presentation :
    https://datatables.net/examples/basic_init/alt_pagination.html

  • catchcatch Posts: 4Questions: 1Answers: 0
    edited December 2020

    my question is : i have lakhs of records in sqlserver. for example (10,00,000)
    Throwing all the records from Stored Procedure and through code to UI is hectic.

    when the page loads i will return only 10 records from stored procedure and if i give that to datatable in pagination only previous,1,next will come.
    i need pagination as 1 to 100 etc based on record count, so that when i click the no.2,3...etc again it will call the database and retrieve next 10 records based on page index.

    i hope this scenario will give more clarity.

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

    As I said above, use serverSide, that's what you need,

    Colin

  • catchcatch Posts: 4Questions: 1Answers: 0

    sure Colin, i will try that
    Thanks

This discussion has been closed.