Does value change in column require redraw?
Does value change in column require redraw?
Hi
I have a checkbox in my datatables(1.10) that when checked another column(checkInDate) in that row gets updated with a date. To update this checkInDate Column I use jquery
$('#datatables').on('change', '.my-checkbox', function(e) {
var $checkInDateColumn = $that.parent().siblings('td').children('.check-in-date');
// ajax call
$checkInDateColumn.text(result);
});
Now I noticed that when I tried to order that column this new date does not get ordered properly. I don't know if this because my manipulation of the column or because this column can have blank dates and I don't know if moment is handling it properly
I do have this set: $.fn.dataTable.moment( 'MM/DD/YYYY' );
but I don't know if this can handle blank dates.
This question has an accepted answers - jump to answer
Answers
You can't just change the HTML (or text in this case) and expect DataTables to know about it I'm afraid.
You need to use either
cell().data()
to change the cell's data via the API, or use your current method and thencell().invalidate()
orrows().invalidate()
to tell DataTables that the data has changed and it should be re-read.Allan
Yea
I thought that would be the case that's what I was hoping just draw would do it all but looks like I need an extra step. I don't really understand how to use cell.data()(not sure what I am passing into it).
Is any one of these method more efficient vs the other?
The easiest code wise is to do:
That will reread the data from all rows, so it is also the slowest option - although with a small / medium sized table, you'll never notice the difference. How large is your table (in rows and columns).
Allan