why Empty message not showing when use of datatable as serverside ?
why Empty message not showing when use of datatable as serverside ?
MithilTatvasoft
Posts: 4Questions: 2Answers: 0
here is my code spinet:
table = $('#example').DataTable({
"language": {
"lengthMenu": "Display _MENU_ records per page",
"zeroRecords": "Nothing found - sorry",
"info": "Showing page _PAGE_ of _PAGES_",
"infoEmpty": "No records available",
"infoFiltered": "(filtered from _MAX_ total records)"
},
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "DataTableServerSide.aspx/GetTableData",
"fnServerData": function (sSource, aoData, fnCallback) {
$.ajax({
"dataType": 'json',
"contentType": "application/json; charset=utf-8",
"type": "GET",
"url": sSource,
"data": aoData,
"success": function (msg) {
var json = jQuery.parseJSON(msg.d);
fnCallback(json);
$("#example").show();
},
error: function (xhr, textStatus, error) {
if (typeof console == "object") {
console.log(xhr.status + "," + xhr.responseText + "," + textStatus + "," + error);
}
}
});
},
responsive: {
details: {
type: 'column',
target: '.glyphicon-info-sign',
display: $.fn.dataTable.Responsive.display.modal({
header: function (row) {
var data = row.data();
return 'Details for ' + data[1];
}
}),
renderer: $.fn.dataTable.Responsive.renderer.tableAll({
tableClass: 'table'
})
}
},
columnDefs: [{
className: 'control',
orderable: false,
targets: 0
}],
order: [1, 'asc']
});
})
Action | USER_NAME | USER_LOCATION | USER_DEPTNAME |
---|
Json rerun when no data found : {"d":"{\"sEcho\": 1,\"iTotalRecords\": 0,\"iTotalDisplayRecords\": 0,\"aaData\": [ ]}"}
This discussion has been closed.
Answers
Not sure. Can you link to a page showing the issue please.
Allan
Hello, Allan here is link
http://test.mithilphotos.com/Admin/DepartmentList.aspx
When I load the page I get three rows shown. If I type 1 into the filtering box there is a Javascript error occuring:
That is being caused by the server returning:
You are then trying to use
$.parseJSON
ond
, hence the error.Allan
yes when there is no data after filtering then blank json returns even i try with : {"d":"{\"sEcho\": 1,\"iTotalRecords\": 0,\"iTotalDisplayRecords\": 0,\"aaData\": [ ]}"} json return as well but no data found message not occur and processing is going on.