ColReorder does not preserve cell content
latagore opened this issue · 2 comments
latagore commented
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();
});
}
Deleted user commented
Can you link to a test page showing the issue please.
latagore commented
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.