fnSetColumnVis deletes data ?
fnSetColumnVis deletes data ?
[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?
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?
This discussion has been closed.
Replies
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