5

Hi I try populate my datatable using feathers service in this way:

app.service('pupils').find({}, (error, result) => {

    $('#pupils > table').DataTable({
        "pageLength": view.short,
        "lengthChange": false,
        "info" : false,
        "responsive": true,
        "data": result.data,
        "deferRender": true,
        "columns": [ ... ]
    });

}); 

I have more than 100 testing records but in callback I receive only 10 records. I receive more records after added below code in feathers service:

paginate: {
   default: 100,
   max: 200
 }

but I would like to disable pagination for received all records from mongo. How can I do that?

SeaDog
  • 645
  • 1
  • 9
  • 32

2 Answers2

9

To disable pagination, remove the paginate option. Not recommended for production however since it might bring down both, the client and the server if you try to send many thousands of records.

Note: the response object changes depending on whether you are using pagination:

Response with pagination: object with data array property

{
   total: 572,
   limit: 50,
   skip: 4,
   data: [/* the data is here */]
}

Response without pagination: the data array

[/* the data is here */]
Ryan Wheale
  • 26,022
  • 8
  • 76
  • 96
Daff
  • 43,734
  • 9
  • 106
  • 120
  • If I disable pagination I receive empty array. I use datatables in my project. I need receive all records from my database, unless you know better solution? `pagination: false`, not works for me. – SeaDog Nov 20 '17 at 13:40
  • Then it's either a bug or something else is wrong in your setup. Removing the `paginate` option or setting it to `false` should work. – Daff Nov 20 '17 at 17:34
  • I know what was wrong. If I used paginate option my result was: `Object { total: 11, limit: 100, skip: 0, data: Array[11] }` without this option or `paginate: false` I recived Array `[ Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, 1 more… ]` in my datatable I had to change result.data to result. Thanks Daff! – SeaDog Nov 21 '17 at 10:16
3

As @daff already pointed out in the answer above, you can disable Pagination in your configuration, although this is really not recommended.

Also you can disable pagination for a service call once in the service call.

service.find({ paginate:false})

This was discussed on Github here

The documentation for this feature can be found here

Yuna
  • 122
  • 9