Capturing The Total Number Of Records
Capturing The Total Number Of Records
tinker1123
Posts: 22Questions: 0Answers: 0
Underneath the DataTables plugin you get a dynamic statement like
"Displaying 1 - 10 of 168 entries"
Is there way to detect when that statement gets updated and is there a way to capture the value of the total ( ie "168" )?
Thanks much in advance either way
Steve
"Displaying 1 - 10 of 168 entries"
Is there way to detect when that statement gets updated and is there a way to capture the value of the total ( ie "168" )?
Thanks much in advance either way
Steve
This discussion has been closed.
Replies
[code]
data['iTotalDisplayRecords']
[/code]
and store in a variable on successful ajax call
( you can get to see this info in firebug / chrome's dev tools XHR tab and check Either Response / JSON after successful ajax call)
Hope this helps
Allan
Yes - as long as you are using server-side processing :-). Doesn't work for client-side processing.
Allan
This is roughly what I did:
The HTML label at the top of my screen above the Datatables Plugin
[code]
${number_of_records_found} Record(s) Found
[/code]
My Script
[code]
$.fn.dataTableExt.oApi.fnUpdateLabelNumRecords = function ( oSettings )
{
$("#number_of_records_found").html(oSettings.fnRecordsTotal());
};
$(document).ready(function() {
$('#results_table').dataTable( {
"bPaginate": true,
"bProcessing": true,
"bServerSide": true,
"sScrollY": height,
"bScrollCollapse":false,
"sScrollX": "600px",
"sServerMethod": "POST",
"sAjaxSource": "/nsd/resultstable",
"aoColumns": aoColumns,
"fnDrawCallback": function(){this.fnUpdateLabelNumRecords();}
} );
} );
[/code]