Dynamically Adding/Removing Columns

Dynamically Adding/Removing Columns

ByteMonkByteMonk Posts: 2Questions: 0Answers: 0
edited December 2012 in General
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
});
});

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Please link to a test case: http://datatables.net/forums/discussion/12899/post-test-cases-when-asking-for-help-please-read

    Are you removing the cells from the table? If not, DataTables will be reusing them.

    Allan
  • ByteMonkByteMonk Posts: 2Questions: 0Answers: 0
    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
This discussion has been closed.