Reputation: 402
I'm using server-side processing in jQuery DataTables, but the rows aren't getting added to the table. They are present in the AJAX success, and the rows are also in the data parameter, but they aren't getting added to the table.
otable = $('#siteselectiontable').DataTable({
"serverSide": true,
"deferLoading": 0,
"processing": true,
"paging": true,
"columns": [{
"data":"RADIO"
},
{
"data":"SITE_DATA"
}
],
"ajax": {
success: function(data) {
if(typeof data['error']!="undefined"){
bootbox.alert({
closeButton: false,
message: "<div class='alert alert-danger' role='alert'>" +
"<strong>Timeout Error: </strong>Please refine your search" +
"</div>"
});
}
},
beforeSend: function() {
$("#siteselectionfooter").after(progress);
},
complete: function() {
$(".loading-mask").remove();
}
},
"searching": false,
"ordering": false,
"lengthChange": false,
"pageLength": 5,
"dom": '<"top"><"pull-right"f>t<"bottom center"p><"clear">',
"fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
$('td:eq(0)', nRow).css({
'text-align': 'center',
'vertical-align': 'middle'
});
}
});
and for the ajax call i am using the below:
table.ajax.url(url).load();
how can i handle the server side error in a custom way ?
Upvotes: 1
Views: 1710
Reputation: 402
i have resolved this with dataSrc
in ajax options and adding the below line
$.fn.dataTable.ext.errMode = 'none';
"ajax": {
beforeSend: function() {
$("#siteselectionfooter").after(progress);
},
complete: function() {
$(".loading-mask").remove();
},
"dataSrc": function ( json ) {
if(typeof json['error']!="undefined"){
bootbox.alert({
closeButton: false,
message: "<div class='alert alert-danger' role='alert'>" +
"<strong>Timeout Error: </strong>Please refine your search" +
"</div>"
});
}
return json.data;
}
},
Upvotes: 2