Cannot empty the table on server-side processing

Cannot empty the table on server-side processing

SoN9neSoN9ne Posts: 7Questions: 1Answers: 0
edited March 2014 in DataTables 1.9
Hello,

I have a datatable that has a purge button to purge the cache on a large dataset. The issue I have is that when the purge button is clicked it sends a request and this can take a few minutes to get a result returned. The table keeps the old records on the table until the new request has come back. I am trying to delete the old records so the loading indicator will be displayed so the user knows what is happening.

I have tried using:[code]proFormaTable.fnClearTable();[/code] and a plugin [code]proFormaTable.fnFilterClear();[/code] (http://datatables.net/plug-ins/api#how_to)

No matter what I try I cannot get the table to empty it's data so the user is sitting on a page with old data. This causes problems because some users don't know much about web and think they are using fresh data...

I am using server side processing and my debug details are: http://debug.datatables.net/usanur

Hopefully this is something stupid I am doing but for now I am completely lost. Thanks for any insight.

Jeremy


If it helps, the rest of the code for the js file is:
[code]
$('#packagesOnly').click(function() {
packagesOnly = !$(this).is(':checked');
// $('#pro-forma-search-form').submit();
filterDataTable();
});

$('#purge-cache').click(function() {
purgeRequest = true;
$('#pro-forma-search-form').submit();
});

// Delay search for input
proFormaSearch.on('keyup', function() {
clearTimeout($.data(this, 'timer'));
var wait = setTimeout(filterDataTable, 500);
$(this).data('timer', wait);
});

// Apply search filters
$('#pro-forma-search-form').on('submit', function(event){
event.preventDefault();
filterDataTable();
});

$(window).bind('resize', function () {
proFormaTable.fnAdjustColumnSizing();
} );

$(window).bind('abortRequest.beforeunload', function() {
abortDatatablesRequest();
});

$('#export-excel').click(function() {
window.open('/reports/package-pro-forma/?dateStart='+encodeURIComponent($('#date-start').val())+'&dateEnd='+encodeURIComponent($('#date-end').val()));
});


/**
* Filter parent items
*/
function filterDataTable() {
// Clear search field
proFormaTable.fnClearTable(true);
var searchString = proFormaSearch.val();
proFormaTable.fnFilter( searchString );
}

/**
* Aborts the datatables request
*/
function abortDatatablesRequest() {
if (proFormaTable !== undefined) {
var oSettings = proFormaTable.fnSettings();
if (oSettings.jqXHR) {oSettings.jqXHR.abort();}
}
}[/code]

Replies

  • SoN9neSoN9ne Posts: 7Questions: 1Answers: 0
    Fix was to do: [code]$('#package-pro-forma-table tbody').empty();[/code]
  • allanallan Posts: 63,494Questions: 1Answers: 10,470 Site admin
    Server-side processing gets its data from the server. So if you want to empty the table, you need to delete all rows on the server-side and then redraw the table.

    Allan
This discussion has been closed.