Quantcast
Channel: DataTables 1.9 — DataTables forums
Viewing all articles
Browse latest Browse all 1816

Post initialise access to multiple datatables on one page

$
0
0
Hi there,

Myself and a fellow developer are having a major headache with this one.

We have (currently) 4 datatables on a single page and two of which we have a checkbox to allow the user to select all of the currently filtered results.
We do this via:
var oTable = $('.downdatatable').dataTable();
		$('input', oTable.$('tr', {"filter": "applied"} )).prop('checked',chk);

However that bit of code is run via a click event on the checkbox and it works, to an extent.
When we reinitialise the datatable (oTable) it duplicates the filters.
This seems to be be because the .downdatatable class we reinitialise is wrapped by a datatable header if re-sets up the table inside of the previous wrapper and we end up with a datatable inside of another datatable wrapper,
If we keep clicking the checkbox the datatable keeps getting smaller and smaller.

We have followed another post that mentions setting up a global array $.fn.dataTableInstances[] and putting the datatable in there.

That also works fine but only for the last table to be initialised.

Allan mentioned the $.fn.dataTableSettings keys need to be the same as the keys in dataTableInstances. However this only ever contains one element which is the last tables settings.

We can load all the datatables via the array but cannot run any functions against it as we get the error:

TypeError: oSettings is null
	

var aoData = oSettings.aoData;

jquery....js (line 4979)

Viewing all articles
Browse latest Browse all 1816

Trending Articles