Table reload not working
Table reload not working
Yurii
Posts: 16Questions: 0Answers: 0
Hi, I'm loading my table from ajax source, and on particular event I want the table to be reloaded, but it doesn't work.
var table = $('#datatable_ajax').DataTable( {
"processing": true,
"serverSide": true,
"pageLength": 25,
"bSortCellsTop": true,
"order": [[ 1, "asc" ]],
"dom": '<"top"l<"add-button-area">>rt<"bottom"flp><"clear">',
"ajax": $.fn.dataTable.pipeline( {
url: 'table_ajax.php',
pages: 5 // number of pages to cache
} ),
"columns": [
{ "data": "id" },
{ "data": "name" },
{ "data": "address" },
{ "data": "city" },
{ "data": "cap" },
{ "data": "province" },
{ "data": "email" },
{ "data": "tag1" },
{ "data": "tag2" }
],
"columnDefs": [{ // set default column settings
'orderable': false,
'targets': [7,8]
}, {
"searchable": true,
"targets": [0,1,2,3,4,5,6]
}, { "sClass": "x-editable",
"aTargets": [1,2,3,4,5,6]
}],
"search": "Search:",
"zeroRecords": "No matching records found",
"fnInitComplete" : function(oSettings, json) {
$( "#datatable_ajax_wrapper > .top div.add-button-area" ).html('<button id="addBtn" class="btn green" data-toggle="modal" href="#responsive"><span class="icon-user-follow" aria-hidden="true"></span> Add </button>');
}
} );
$('#addBtn').on('click', function () {
table.ajax.reload();
});
I also tried simply adding a new row, but this doesn't work either
$('#addBtn').on('click', function () {
table.row.add({
'id': 'AAAdata',
'name': 'data',
'address': 'data',
'city': 'data',
'cap': 'data',
'province': 'data',
'email': 'data',
'tag1': 'data',
'tag2': 'data'
} ).draw();
});
Any suggestion on how to fix this?
Thanks
This discussion has been closed.
Replies
Ok, I'm sorry for the useless post, but considered I'm using a Pipelining function, I had to draw the table with: