destroy table option
destroy table option
Allan,
I tested (not as extensively as your test cases) the following as an option to include for destroying the table.
[code]
/* Sanity check that we are not re-initialising a table - if we are, alert an error if not a destroy */
for (i = 0, iLen = _aoSettings.length; i < iLen; i++) {
if (_aoSettings[i].nTable == this) {
if (oInit.destroy == true) {
_aoSettings.splice(i, 1);
return;
}
else {
alert("DataTables warning: Unable to re-initialise DataTable. " +
"Please use the API to make any configuration changes required.");
return _aoSettings[i];
}
}
}
// if still here and destroy was called, then the table not found
// so return
if (oInit.destroy == true) {
return;
}
[/code]
This can be called as follows:
[code]
$("#example").dataTable({"destroy":true});
// to remove the table from page... could be added to DataTables destroy.
$("#example").remove();
[/code]
May not the best long-term solution, but it's an idea.
One more thing... Because of the way DataTables is constructed with private and public functions, this doesn't affect any other tables in a multi-table situation.
Patrick
I tested (not as extensively as your test cases) the following as an option to include for destroying the table.
[code]
/* Sanity check that we are not re-initialising a table - if we are, alert an error if not a destroy */
for (i = 0, iLen = _aoSettings.length; i < iLen; i++) {
if (_aoSettings[i].nTable == this) {
if (oInit.destroy == true) {
_aoSettings.splice(i, 1);
return;
}
else {
alert("DataTables warning: Unable to re-initialise DataTable. " +
"Please use the API to make any configuration changes required.");
return _aoSettings[i];
}
}
}
// if still here and destroy was called, then the table not found
// so return
if (oInit.destroy == true) {
return;
}
[/code]
This can be called as follows:
[code]
$("#example").dataTable({"destroy":true});
// to remove the table from page... could be added to DataTables destroy.
$("#example").remove();
[/code]
May not the best long-term solution, but it's an idea.
One more thing... Because of the way DataTables is constructed with private and public functions, this doesn't affect any other tables in a multi-table situation.
Patrick
This discussion has been closed.
Replies
Yup - that is not a bad idea at all. I quite like the idea of a dev being allowed to do it intentionally, but they get the alert() if not. I think I'd like to complete the destructor to restore the DOm to it's original state - but that should be perfectly do-able... One for a future version this I think. Thanks.
Allan
Patrick
First of all I wanted to thank you for your great work. It's really awesome.
I would like to "refresh" my table after an Ajax call.
I tried several pieces of code to refresh my table but none of them worked.
my original resulting html code when I arrive on my page:
[code]
hdata1
hdata2
hdata3
hdata4
hdata5
data1
data2
data3
data4
data5
//<![CDATA[
jQuery.noConflict();
var oTable;
function initDataTablesList(){
jQuery(document).ready(function($) {
oTable = $('#list_handledList').dataTable( {
"bPaginate": true,
"bLengthChange": true,
"bFilter": true,
"bSort": true,
"bInfo": true,
"bAutoWidth": true,
"oLanguage": {
"sProcessing": "Chargement...",
"sLengthMenu": "Afficher _MENU_ r
I tried to incorporate your code from the one you posted on this thread,
It get rid of the alert Warning but it displays- 2 Show entries, search box, showing label at the bottom..
any idea on this one?
I'm a newbie in jquery so bare with me..
thanks for the help in advance..
It's probably best to start a new thread for this subject now, ideally with a link and your initialisation code :-). I guess you are initialising the table times - which you probably don't want to do...
Allan