How to work pagination in jquery datatable library?

问题内容:

I’m working with jquery datatable library on my project,I have a question about pagination in it. I want to know is jquery datatable load all of data in RAM and after that it does paging on data.for example if I have 2000 records in database is jquery datatable load all of 2000 records and after that paging it? or by default, for example it loads 10 to 10 records.

  $('#repAll').DataTable({
    "language": {
        "search": "جستجو",
        "paginate": {
            "previous": "قبلی",
            "next": "بعدی"
        },
        "sLengthMenu": "نمایش  _MENU_  ردیف",
        "sInfo": "نمایش _START_ تا _END_ ردیف از _TOTAL_ ردیف",
        "sEmptyTable": "هیچ داده ای در دسترس نیست",
        "sInfoEmpty": "نمایش 0 ردیف  از 0 ردیف",
    }

});

问题评论:

答案:

答案1:

Where you need pagination, at the db end or at client?

If you have less data you can use client paging, by default it is enabled:

$('#repAll').DataTable({
 "paging": false, // can make false to disable paging
 "pagingType": "full_members" // to display all buttons i.e. first, previous, next, last
});

For serverside paging you need to add following attribute:

$('#repAll').DataTable({
  "serverside":true
});

that will add optional parameters for your index like ‘start’ and ‘length’. You can use start and length parameters to fetch the records.

答案评论:

原文地址:

https://stackoverflow.com/questions/47754128/how-to-work-pagination-in-jquery-datatable-library

添加评论