pagination using jquery datatable

2019-09-15 04:39发布

问题:

I am doing pagination using jquery datatable. My data is not exctaly table, 1 row from db say id, name, location...... i display in jsp in 3 rows like first row id,second row name then third row location...i have 1500 hunderd rows in db. For this i need to do pagination. And also when the user clicks on next link it should go to server for next records.

I know how to get the restricted number of results from server side ....

I need help for jsp configuration.....i am new to jquery...how to configure datatable.

Any ideas how to do it?

回答1:

As you can see here you can set "bProcessing": true, "bServerSide": true and the source "sAjaxSource": "yourFile.php" when you init your table.
Then on your php you have to return the same object as bellow:

{
  "sEcho": 1,
  "iTotalRecords": "57", // total number of rows
  "iTotalDisplayRecords": "57", // number of rows after the filter
  "aaData": [//your data]
}

You can see what parameters you have to use on the server-side processing reference.