fnDraw doesn't redraw after server side processing

fnDraw doesn't redraw after server side processing

tpepernictpepernic Posts: 12Questions: 0Answers: 0
edited August 2013 in General
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...

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    > I'm using pipelining if that makes any difference...

    It does - its getting the data from the cache. You need to either clear the cache or not use pipelining.

    Allan
  • tpepernictpepernic Posts: 12Questions: 0Answers: 0
    Is there a way to force clearing the cache with pipelining?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Assuming you are using the code form this example: http://datatables.net/release-datatables/examples/server_side/pipeline.html - just set `oCache.iCacheLower = -1` .

    Allan
  • tpepernictpepernic Posts: 12Questions: 0Answers: 0
    Brilliant, thanks.
  • pmirandapmiranda Posts: 10Questions: 0Answers: 0
    And what if you're not using pipeline?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    If you are not using pipelining fnDraw will always hit the server. If it isn't please link to a test case showing the issue.

    Allan
This discussion has been closed.