Check if a table element is datatables initialized
Check if a table element is datatables initialized
Hello there,
I want to check if a table element with say, id="datatable" is datatables-initialized. Something like this:
if ($(#datatable).dataTable().initialized) alert("initialized!") else alert("not initialized!");
How can I do that?
Thanks!
I want to check if a table element with say, id="datatable" is datatables-initialized. Something like this:
if ($(#datatable).dataTable().initialized) alert("initialized!") else alert("not initialized!");
How can I do that?
Thanks!
This discussion has been closed.
Replies
[code]
function isDataTable ( nTable )
{
var settings = $.fn.dataTableSettings;
for ( var i=0, iLen=settings.length ; i
[code]if ( settings[i].nTable == nTable )[/code]
istead. Just came across that problem :-)
TD;DR for lazy persons:
[code]
function isDataTable ( nTable )
{
var settings = $.fn.dataTableSettings;
for ( var i=0, iLen=settings.length ; i
Regards,
Allan
--- What a truly helpful post and function. I'm using this as part of generalized jQuery based tab handler that is 'smart' enough to detect dataTables on the tab pane being displayed and invoke the columnAdjustment function. Spot on, Allan.
Allan
New: Static API method - fnIsDataTable - check if a TABLE node is a DataTable or not
New: Static API method - fnTables - get the DataTables that are initialised on the table (optionally limit to just the visible tables)
I think these will be really useful (I know in my own use of DataTables when working with fairly complex cases these would be useful) so are now in the core and will be included in 1.9.1.
Regards,
Allan