Dynamically Adding/Removing Columns
Dynamically Adding/Removing Columns
I am using DataTables in a manner such that the rows or columns can change depending on how the user turns various filters on/off. When the user applies the filter the DataTables widget gets reinitialized. Rows work great but I am seeing some weirdness with columns. I tried the workaround where I set bDestroy to true when reinitializing the DataTables widget. If the number of columns increases it works just fine. If the number of columns goes down I am getting some trailing column headers with nothing under them. I checked my aoColumns and everything looks correct. Any ideas what could be happening?
My initialization code looks like this:
$.getJSON(url, null, function(json) {
$("#example").dataTable({
"bProcessing": true,
"aaData": json.aaData,
"aoColumns": json.aoColumns,
"bDestroy": true
});
});
My initialization code looks like this:
$.getJSON(url, null, function(json) {
$("#example").dataTable({
"bProcessing": true,
"aaData": json.aaData,
"aoColumns": json.aoColumns,
"bDestroy": true
});
});
This discussion has been closed.
Replies
Are you removing the cells from the table? If not, DataTables will be reusing them.
Allan
Here is a test case link:
http://live.datatables.net/apoyav
Hopefully that should be enough to see what I am doing wrong.
Jeff