Store reference to dataTable object
Store reference to dataTable object
philipstreet
Posts: 5Questions: 0Answers: 0
Hi All,
Config : using jQuery v1.3.2 and DataTables 1.5.4 - I can't upgrade to the latest versions as that breaks all my tables.
I want to be able to store a reference to the dataTable object so that I can retrieve it later. For example, I want to do something like this;
[code]
$(document).ready(function() {
var $container = $("#container");
var $dt = $("#table").dataTable();
$container.data("dt", $dt);
}
function doSomethingGenericWithADataTable(container) {
var $currentDT = $(container).data("dt");
// blah blah blah
}
[/code]
The reason being is that I'm creating a ASP.NET User Control containing a DataTable, and this control will be used several times on the same ASPX page. I'm trying to write as much generic code as possible in the control for performing the various operations on the DataTable. So I need to store references to the DataTables somehow so I can retrieve and use them later.
Kind regards,
Phil
Config : using jQuery v1.3.2 and DataTables 1.5.4 - I can't upgrade to the latest versions as that breaks all my tables.
I want to be able to store a reference to the dataTable object so that I can retrieve it later. For example, I want to do something like this;
[code]
$(document).ready(function() {
var $container = $("#container");
var $dt = $("#table").dataTable();
$container.data("dt", $dt);
}
function doSomethingGenericWithADataTable(container) {
var $currentDT = $(container).data("dt");
// blah blah blah
}
[/code]
The reason being is that I'm creating a ASP.NET User Control containing a DataTable, and this control will be used several times on the same ASPX page. I'm trying to write as much generic code as possible in the control for performing the various operations on the DataTable. So I need to store references to the DataTables somehow so I can retrieve and use them later.
Kind regards,
Phil
This discussion has been closed.
Replies
[code]
$(document).ready(function() {
var $container = $("#container");
var dt = $("#table").dataTable();
$container.data("dt", dt);
}
function doSomethingGenericWithADataTable(container) {
var $currentDT = $(container).data("dt");
// blah blah blah
}
[/code]
Quite simple really, I suppose.
Phil
Allan
Thanks for your reply.
I tried that already but each time I do that the DataTable header and footer are added to the table. That might be a quirk of the version (1.5.4) I'm using.
Regards,
Phil
Allan
I believe "bonkers" is an accurate description of what I've been experiencing... :-)
Phil