Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 81990

Error Message ("Cannot reinitialise DataTable") When Table is Blank

$
0
0
I am using dataTables 1.7.3 and obviously I love it.... a truly amazing script!

I am, however, having a small problem that I'm hoping someone can help with.

I have the script setup to run on a 7 column table using the following code:

<link href="/jquery/plugins/datatables/media/css/custom_table.css" rel="stylesheet" type="text/css" />
script src="/jquery/jquery-1.4.3.min.js" type="text/javascript"></script>
<script src="/jquery/plugins/datatables/media/js/jquery.dataTables.js" type="text/javascript"></script> <!-- Interactive tables -->
<!-- dataTables end -->
 
<script>
 
$(document).ready(function() {
	$('#datatable').dataTable( {
		"aoColumns": [
			{ "sType": "html",
			"sWidth": "200px"},
			{ "bSearchable": false},
			{ "bSearchable": false},
			{ "bSearchable": false},
			{ "bSearchable": false},
			{ "bSearchable": false},
			{ "sWidth": "140px" }
		],
		"bJQueryUI": false,
		"sPaginationType": "full_numbers",
		"iDisplayLength": 25,
		"bAutoWidth": false,
		"aaSorting": [ ] // Prevents initial sorting 
 
 
		} );
} );
 
</script> 


Normally this works perfectly.

The data for this table is dynamic in the sense that when a user loads the page, our system fetches the information from our database and plugs it into the table. Then DataTables works it's magic!

The problem is that there are times when the table will be empty. When this happens, we have this code appear in the table:
<tbody>
  <tr>
<td height="30" align=center colspan="7">You do not have any current emails. <a href="?action=sample">Click here</a> to create a new one.</td>
  </tr>
</tbody>

But, as soon as that happens, there is a popup alert saying:
DataTables warning (table id = 'datatable'): Cannot reinitialise DataTable.

To retrieve the DataTables object for this table, please pass either no arguments to the dataTable() function, or set bRetrive to true. Alternativly, to destroy old table and create a new one...ETC.

Is there a way to prevent this from happening? Any insight is greatly appreciated!

Thanks in advance.

Viewing all articles
Browse latest Browse all 81990

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>