Clear the table of all data. clear()
Clear the table of all data. clear()
abkrim
Posts: 2Questions: 1Answers: 0
I try use method clear() for clear data on table before add data.
I've a component Calendar. On this I put code for clear and add data, but not work.
I like clear data if user click on one day with events, for table only show events on this day, not events on this and older day.
if (tableUse === true) {
var giCount = 1;
$dowElement.addClass('event-clickable');
$('#' + id).click(function() {
var table = $('#example').DataTable();
table
.clear();
$('#myTable').dataTable().fnAddData([
value.id,
value.date,
value.title,
"test"
]);
})
also try
$('#myTable').dataTable().clear();
http://dashboard.cprsync.com/full
user: cprsync
pass: testtest
This discussion has been closed.
Answers
I would suggest picking the legacy API (fnAddData, fnClear, etc) or the new API (
row.add()
,clear()
, etc) and sticking to it rather than using both.You also have two different tables being selected with the above code:
note the difference in the ids...
Allan
Apreciate you help. I had some problems understanding the use of the API.
With
it works perfectly.
Good to hear. I would recommend the new API (
$('#myTable').DataTable().clear().draw();
) if you can use it, since the legacy API will eventually be removed (v2).Allan