Processing server datatables with an unknown number of rows

Does datatables have any server-side support for retrieving data where the rocordsTotal count is not known in advance ?

We have data for which a request for a final bill is almost as expensive as a request for all records. This would be necessary if there was a way to tell datatables that the number of recordsTotal is unknown. Such functionality is not documented. Is it supported?

Update 1: I think I didn’t fully explain my problem and tried to ask the abstract version. I am using the datatables.net/extensions/scroller plugin and it works with the ajax option. If I use a large number for recordsTotal , then the user can go to the button and I have no data to show there. The same is true when paginated, the user can click on the page number, which may not exist.

+8
javascript jquery datatable
source share
1 answer

I assume that "TotalRecords" means the field "recordsTotal" in the object that the server returns in datatables. You can simply take an account for the following N pages that match your search criteria, set this value to "recordsFiltered" and "recordsTotal", and not display the total score of records using the "dom" option: http://datatables.net/reference/ option / dom note component i. This is not built-in functionality, but it is a convenient way to work around a previously unknown number of tables.

Doing this will let the Datatables know that you have at least N pages to view through the "recordsFiltered" field, so pagination works correctly. Thus, Datatables need not know exactly how many records you have in order to work.

You can also use the footerCallback option to customize the data summary below the table. Have a look here: https://datatables.net/examples/advanced_init/footer_callback.html

Also, since you mentioned in the comment that you are using postgresql, I don’t know if this applies to you or not (I never used postgresql) https://wiki.postgresql.org/wiki/Count_estimate

+3
source share

All Articles