I need to make a comparison with the total value of records that exist in the database, in a given table. I could get this value via PHP, and pass it to JavaScript, while rendering the page, however, the records can be dynamically added / deleted, and then the total records can be changed. In fact, what interests me is and make a comparison with the total of displayed values (or that can be displayed in the case of pagination), because for the user, the table reflects the bank.
I do not think it's a good solution to create an Action in the controler, just to answer a request for that value, since "theoretically" I have it available.
The datatable configuration:
$("#datagrid").DataTable({
oLanguage: DT_PTBR,
dom: 'l<"toolbar-h"fT>rtip',
"ajax": {
"url": "/datatable-data",
As the load is dynamic, the solution counting table rows does not work.
I searched for a solution, and found suggestions for getting the value I want this way:
oTable.fnSettings (). fnRecordsTotal ()
In this case, it did not give clues as to how oTable
could be obtained. So I researched for a way to get this "object", and apparently it's gotten that way:
var oTable = $("#datagrid").DataTable({
But when using this object, in the solution above, an error occurs ("fnSettings", not a function). I tried this way too:
$("#datagrid").DataTable().fnSettings().fnRecordsTotal()
and
$("#datagrid").DataTable().fnRecordsTotal()
But without success.