Can i make function to reload datatable
Can i make function to reload datatable
Hi, I'm new
I make some program with datatable,
When i want try to input data, after process insert data automatically reload table
Here is my example code :
function dataTableCall(NameData){
if(NameData == "kategori"){
var table = $('#table_control').DataTable({
"ajax": BaseURLBack() + '/data/table_' + NameData + '.php?NAMEDATA=' + NameData,
"paging": true,
"lengthChange": false,
"searching": true,
"ordering": true,
"info": false,
"autoWidth": true,
"columnDefs": [
{
"targets": -1,
"data": null,
"render": function ( data, type, full, meta ) {
var FirstButton = '<a href=\'' + data[ 2 ] + '\' class=\'btn btn-info btn-sm ripple-effect\' style=\'margin-bottom:5px;\' data-toggle=\'modal\' data-target=\'#EditModal\'><i class=\'fa fa-pencil\'></i> Edit</a>';
var SecondButton = '<a href=\'' + data[ 3 ] + '\' class=\'btn btn-danger btn-sm ripple-effect\' style=\'margin-bottom:5px;\' data-toggle=\'modal\' data-target=\'#DeleteModal\'><i class=\'fa fa-pencil\'></i> Hapus</a>';
return FirstButton + ' ' + SecondButton;
}
}
],
"language": {
"processing": "
"
},
"processing": true
});
}
}
function ReloadDataTable(){
table.ajax.reload();
}
i try to calling ReloadDataTable() , but function not work.
How to fix this ?
Thanks
Replies
ReloadDataTable
probably doesn't have access to the variabletable
. Try:$('#table_control').DataTable().ajax.reload();
.Allan
OMG thanks allan, you safe my life >_<
That's work for me.
THANKS YOU SO MUCH ...