Having Trouble With fnStandingRedraw
Having Trouble With fnStandingRedraw
I've got a DataTable system where I use one rather long script to initialize one of 4 different tables, certain options are built dynamically when the table is initialized (if you need to see it: http://pastebin.com/3fPCcFty).
I'm using modals from Twitter Bootstrap to display the relative input form when a user clicks on any of the rows, which allows the user to edit the database information for the row that was clicked.
Now I need to refresh the table (either as a whole or just the updated row) after the information has been updated, but I can't get fnStandingRedraw() to work for me. I've also tried using fnTables() to find the active table, fnDestroy to destroy it, and fnDraw() to redraw it again, but still no luck.
Please could someone help me work out how to refresh the table's contents from a different JS function? I'm getting myself really confused here.. :/
I'm using modals from Twitter Bootstrap to display the relative input form when a user clicks on any of the rows, which allows the user to edit the database information for the row that was clicked.
Now I need to refresh the table (either as a whole or just the updated row) after the information has been updated, but I can't get fnStandingRedraw() to work for me. I've also tried using fnTables() to find the active table, fnDestroy to destroy it, and fnDraw() to redraw it again, but still no luck.
Please could someone help me work out how to refresh the table's contents from a different JS function? I'm getting myself really confused here.. :/
This discussion has been closed.
Replies
The DB information is being updated from a completely separate function to the datatable initialization, all I want is to reload my table in the AJAX callback. As far as I can see, it should be as simple as just reloading the datatable... But whether I try destroy it first or not, I just can't get it to reload.
I cannot post any example code other than the pastebin I linked to above. The most recent of countless attempts to do this has left me with the script starting as follows:
[code]/* DataTables
------------- */
function initDataTable() {
var table = $.fn.dataTable.fnTables(true);
if (table.length > 0) {
console.log('table needs to be refreshed');
var oTable = $('#dataTable').dataTable();
// This is the problem, neither of these do anything...
// oTable.fnStandingRedraw();
// oTable.fnDraw();
} else {
console.log('new table must be created');
$(function() {
var dataTableSource = $('#dataTable').attr('data-tablesource');
var dataDetailsSource = $('#dataTable').attr('data-detailssource');
// The rest of the original init script as seen in the linked PasteBin continues here
[/code]
The two console.log() lines show me that the 'if' condition does trigger correctly, but whether I try fnDraw or the fnStandingRedraw (obviously, with un-commenting one or the other from the example code above), nothing happens.
Please can somebody help?