Test datatable exists
Test datatable exists
Is there any easy way to test if a datatable has been created?
I have a script that reloads several tables, but it stops if a reload is called on a table that hasn't been created yet.
table1.fnReloadAjax();
table2.fnReloadAjax();
table3.fnReloadAjax(); <--- If this doesn't exist, script stops here
table4.fnReloadAjax();
I've tried testing length, but that always returns 1?
I have a script that reloads several tables, but it stops if a reload is called on a table that hasn't been created yet.
table1.fnReloadAjax();
table2.fnReloadAjax();
table3.fnReloadAjax(); <--- If this doesn't exist, script stops here
table4.fnReloadAjax();
I've tried testing length, but that always returns 1?
This discussion has been closed.
Replies
All datatables have been created, but the Ajax Source is set to null and loaded later. Some tables are loaded with data and others not. I need to test the table to see if it has been loaded with data?
table1.fnSettings().sAjaxSource
Or you could see if there is any data in the table:
table1.fnSettings().aoData.length (would fall over if there is truly no data to be display perhaps?)
Or similar to the aoData length, you can use the DOM:
$('#table_id tbody tr').length
Allan