When should I count the total records in a jQuery DataTable?
I want to check common records in jQuery DataTable and hide / show No Record Found message. Currently I have checked the complete lines in the "fnDrawCallback" section like this, but I will show "no entry" when moving too fast:
//Instantiate the Datatable
function configureDataTable() {
var url = prepareURLforDataTable();
$scope.table = $('#example').dataTable({
"bServerSide": true,
"sAjaxSource": url,
"sAjaxDataProp": "aoData",
"bProcessing": false,
"bDestroy": true,
"bPaginate": true,
"bInfo": true,
"bSort": false,
"searching": false,
"bLengthChange": false,
"iDisplayLength": 7,
"fnDrawCallback": function (oSettings) {
//to hide or show no record message
var rowsData = $('#example').DataTable().rows().data();
$scope.count = rowsData.length;
if ($scope.count == 0) {
$scope.ShowNoRecordMsg();
}
else {
$scope.HideNoRecordMsg();
}
$rootScope.hideSpinner();
//other operations
I have two Div for "no entries" and stuff for "conversation table". $ scope.ShowNoRecordMsg and $ scope.HideNoRecordMsg remove display: none of the "no entry" divs and "conversation table" respectively.
+3
source to share
No one has answered this question yet
Check out similar questions: