fnSetColumnVis deletes data ?

fnSetColumnVis deletes data ?

markjomarkjo Posts: 66Questions: 0Answers: 0
edited January 2013 in General
[code]function toggleIt() {
var indices = [];
$("#myTable tbody tr").first().children("td.myclass").each(function(){
indices.push($(this).index());
});
alert("indices:" + indices);
for(var ind in indices)
{
var iCol = indices[ind];
var bVis = oTable.fnSettings().aoColumns[iCol].bVisible;
oTable.fnSetColumnVis( iCol, bVis ? false : true );
}
}[/code]

When I run toggleIt(), I get [quote]"indices: 4,6,7"[/quote] inside alert dialog box. Then 4,6 and 7th columns are hidden.
When I run toggleIt() again I get an empty indices array.

When I check DOM, I see that 4,6 and 7th columns are deleted.
Does "fnSetColumnVis" deletes the columns? Is it possible to just hide rather than delete the data?

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    > Does "fnSetColumnVis" deletes the columns?

    No it doesn't. However, you can't just dynamically add a column to a DataTables by manipulating the DOM as you are. See: http://datatables.net/faqs#append

    Allan
This discussion has been closed.