fnDraw doesn't redraw after server side processing
fnDraw doesn't redraw after server side processing
I can't figure out why fnDraw is not working. I have a table with a checkbox at the end to select one or more rows to delete. The delete is on the server and works if I refresh the page (the XHR fires correctly). Any ideas on what I can debug to figure out why fnDraw is not working?
[code]
//first init
var oTable = jQuery('#webcam-table').dataTable({
"sPaginationType": "full_numbers",
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "index.php?option=com_recordings&task=getRecordings&format=json",
"fnServerData": fnDataTablesPipeline,
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
nRow.className = "videorow";
return nRow;
},
"bStateSave": true,
"aaSorting": [[1,"desc"]],
"oLanguage": {
"sZeroRecords": "No records" },
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [ 3 ] }
]
});
//now delete button clicked after selecting rows
jQuery(".deletebutton").on("click", function(e) {
e.preventDefault(); //cancel click event on start
var testchecked = jQuery(':checkbox:checked').length;
if (testchecked == 0) {
alert('Click checkbox first');
e.preventDefault();
}
else
{
if (confirm('Are you sure you want to delete'))
{
var checked = jQuery('input:checkbox:checked').map(function () {
return this.value;
}).get();
var $this = jQuery(this);
jQuery.ajax({
type: 'POST',
url: 'index.php?option=com_recordings&task=deletevideos&'+getToken()+'=1',
data: {checkedarray:checked},
success: function(data){
//redraw doesn't work but I get into this function.
oTable.fnDraw();
}
});
}
}
});
[/code]
I'm using pipelining if that makes any difference...
[code]
//first init
var oTable = jQuery('#webcam-table').dataTable({
"sPaginationType": "full_numbers",
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "index.php?option=com_recordings&task=getRecordings&format=json",
"fnServerData": fnDataTablesPipeline,
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
nRow.className = "videorow";
return nRow;
},
"bStateSave": true,
"aaSorting": [[1,"desc"]],
"oLanguage": {
"sZeroRecords": "No records" },
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [ 3 ] }
]
});
//now delete button clicked after selecting rows
jQuery(".deletebutton").on("click", function(e) {
e.preventDefault(); //cancel click event on start
var testchecked = jQuery(':checkbox:checked').length;
if (testchecked == 0) {
alert('Click checkbox first');
e.preventDefault();
}
else
{
if (confirm('Are you sure you want to delete'))
{
var checked = jQuery('input:checkbox:checked').map(function () {
return this.value;
}).get();
var $this = jQuery(this);
jQuery.ajax({
type: 'POST',
url: 'index.php?option=com_recordings&task=deletevideos&'+getToken()+'=1',
data: {checkedarray:checked},
success: function(data){
//redraw doesn't work but I get into this function.
oTable.fnDraw();
}
});
}
}
});
[/code]
I'm using pipelining if that makes any difference...
This discussion has been closed.
Replies
It does - its getting the data from the cache. You need to either clear the cache or not use pipelining.
Allan
Allan
Allan