DataTables/ColReorder

ColReorder does not preserve cell content

latagore opened this issue · 2 comments

For one column in my data table, I use render to create a button. When this button is clicked, it loads additional content in the cell. However, when I re-order the column, the cell content is replaced with the original button.

"render": function(data, type, row, meta) {
  if (data != null) {
    return data;
  } else {
    var cellContent = '<a href="#" class="show_nodes">Show Nodes</a>';
    return cellContent;
  }
}

createdCell: function(td, cell, row){
  $(td).on('click', '.show_nodes', function() {
    var url = 'some_url';
    $(td).load(url);
    table.cell(td).data(td.innerHTML).invalidate().draw();
  });
}

Can you link to a test page showing the issue please.

Sorry! This issue was caused because I used the AJAX $.load, but changed the DataTables cell data before it was loaded. I fixed this by updating the cell data when the data is actually loaded.