bVisible not working

bVisible not working

ajgivajgiv Posts: 2Questions: 0Answers: 0
edited June 2012 in General
I have 2 tables, one that is loaded when the page loads and another that is done via ajax. I am creating each table based off the id of the table. When you click a radio button, it hides the one div and shows the other and creates the table. I can only get the ajax loaded table to appear if i destroy the previous one.

That all works fine but it breaks when I want to hide certain columns. It works fine for the non-ajax table, but when i do anything related to hiding columns the table data will not appear at all.

Here is what I have tried using aoColumns and aoColumnDefs.

[code]
oTable.fnDestroy();
oTable = $('#searchT').dataTable({
"sPaginationType": "full_numbers",
"aaSorting": [[ 7, "desc" ]],
"aoColumns": [
/* col1*/ {"bVisible": false },
/* col2*/ {"bVisible": false },
/* col3*/ {"bVisible": false },
/* col4*/ null,
/* col5*/ null,
/* col6*/ null,
/* col7 */ null,
/* col8*/ null,
/* col9 */ null
]
});

oTable = $('#searchT').dataTable({
"sPaginationType": "full_numbers",
"aaSorting": [[ 7, "desc" ]],
"aoColumnDefs": [
{ "bVisible": false, "aTargets": [ 0,1,2,8 ] },
{ "bSortable": false, "aTargets": [ 0,1,2 ] }
],
"aLengthMenu": [15, 25, 50],
"bScrollCollapse": false,
"iDisplayLength": 15,
"bRetrieve": true
});
[/code]

I even created a function so i can use the console in Chrome to hide it, and that's the only way it will hide. Any one have any ideas on why I cannot hide columns?

Replies

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    You can't change a DataTables' configuration since it has been initialised - you would need to destroy the old table and then create your new one, with your new configuration. At the moment, bRetrieve is explicitly telling DataTables to ignore your second configuration above and just return the instance to oTable.

    Allan
This discussion has been closed.