"cannot reinitialise" when hiding columns
"cannot reinitialise" when hiding columns

I have a dataTable that is drawn, after which I am dynamically hiding a column. if the table is redrawn from another action, I get a "cannot reinitialise" error when my column-hiding code is hit.
I've tried conditioning on isDataTable() and then using retrieve to get the existing object, but it still errors. how can I restructure this so that I don't hit that error
$(document).ready(function(){
if ($.fn.dataTable.isDataTable('.group-selector')) {
//this works on initial page load
var tblGroups = $('.group-selector').dataTable();
tblGroups.fnSetColumnVis(5, false);
}
else {
//oddly, this errors when table is redrawn
var tblGroups = $('.group-selector').dataTable({
"retrieve": true
});
tblGroups.fnSetColumnVis(5, false);
}
});
This discussion has been closed.
Answers
Its difficult to say without being able to see the page (per the forum rules ;-) ), but my guess is that the selector is picking up a second table.
Perhaps try:
Do you have any other tables? Or does it use scrolling?
Allan