Multiple tables
Multiple tables
I'm creating multiple tables. I'm using qunit to unit test.
my code is:
[code]
$('table[id^=print_tbl]').each(function() {
var holder = $('#' + this.id).dataTable({
bDestory: true,
bSort: true,
bFilter: true
});
var index = this.id;
tables[index] = holder;
});
[/code]
I need to have access to each individual table, because i then send each tables sorted and filtered to the server.
[code]
var vendorData = {};
var table = tables[index];
if ($('#' + index).is(':visible')) {
vendorData[index] = table.fnGetDisplayedData();
}
return vendorData;
[/code]
this appears to work except, I end up with about 62 items dataTableSettings. They are duplicates. I looked at you code at line 5987:
[code]
if ( _aoSettings[i].nTable == this )
[/code]
This doesn't let me destroy the tables.
my code is:
[code]
$('table[id^=print_tbl]').each(function() {
var holder = $('#' + this.id).dataTable({
bDestory: true,
bSort: true,
bFilter: true
});
var index = this.id;
tables[index] = holder;
});
[/code]
I need to have access to each individual table, because i then send each tables sorted and filtered to the server.
[code]
var vendorData = {};
var table = tables[index];
if ($('#' + index).is(':visible')) {
vendorData[index] = table.fnGetDisplayedData();
}
return vendorData;
[/code]
this appears to work except, I end up with about 62 items dataTableSettings. They are duplicates. I looked at you code at line 5987:
[code]
if ( _aoSettings[i].nTable == this )
[/code]
This doesn't let me destroy the tables.
This discussion has been closed.
Replies
[code]
var tables = newVendorTables();
var myTestTablesContent = '';
var messageEvent = {
content: function(url) {
$.ajax({
type: 'GET',
url: url,
async: false,
success: function(content) {
myTestTablesContent = content;
}
});
}
};
messageEvent.content('../../application/batch.print.php');
module("test for dataTables", {
setup: function() {
$('').appendTo('body');
$('.contentContainer').html(myTestTablesContent);
tables.initTables();
},
teardown: function() {
$('.contentContainer').remove();
}
});
should('validate that there is only two tables in dataTableSettings destroy all tables', function() {
$('.contentContainer').remove();
$('').appendTo('body');
$('.contentContainer').html(myTestTablesContent);
tables.initTables();
var createdTables = tables.getTables();
var table = createdTables['print_tbltest'];
same(table.dataTableSettings.length, 2);
});
[/code]
Regards,
Allan