0
ファイル私はデータテーブルの異なるファイル内の関数を入れた項目 を削除する機能を使用した後、私のDataTableのデータをリロードする必要があります これは私の削除機能である:リロードのdataTableアヤックスソースが
function removeFunction(table,id) {
var txt= $('.titleSup').text();
var txt2= $('.textSup').text();
swal({
title:"Delete",
text: txt,
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes !",
cancelButtonText: "No, cancel",
closeOnConfirm: false, closeOnCancel: false
}, function(isConfirm){
if (isConfirm) {
$.ajax({
url: "ajax/delete.php?for="+table+"&id="+id,
success : function(data){
if(data == 'ok'){
swal({
title:"Delete",
text: txt2,
type: "success",
confirmButtonColor: "#AEDEF4",
confirmButtonText: "Ok",
closeOnConfirm: true,
}, function(isConfirm){
//reload here
});
}else{
swal("Error, try again", "", "error");
}
}
}); // end ajax call
} else {
swal("Cancel", "", "error");
}
});
}
、これが私のデータテーブルのファイルです:
var TableData = function() {
//function to initiate DataTable
//DataTable is a highly flexible tool, based upon the foundations of progressive enhancement,
//which will add advanced interaction controls to any HTML table
//For more information, please visit https://datatables.net/
var runDataTable = function() {
var oTable = $('#sample_1').dataTable({
"sAjaxSource": 'ajax/get_companys.php',
"aoColumns": [
{ "mData": "register_no" },
{ "mData": "name" },
{ "mData": "email" },
{ "mData": "phone" },
{ "mData": "fax" },
{ "mData": "nbr_customer" },
{ "mData": "nbr_user" },
{ "mData": "created" }
],
"aoColumnDefs": [{
"aTargets": [0]
}],
"oLanguage": {
"sLengthMenu": "Show _MENU_ Rows",
"sSearch": "",
"oPaginate": {
"sPrevious": "",
"sNext": ""
}
},
"aaSorting": [
[2, 'desc']
],
"aLengthMenu": [
[5, 10, 15, 20, -1],
[5, 10, 15, 20, "All"] // change per page values here
],
// set the initial value
"iDisplayLength": 10,
});
};
return {
//main function to initiate template pages
init: function() {
runDataTable();
}
};
}();
私はデータテーブルの要素にアクセスし、RemoveFunctionでのAJAX呼び出しの成功機能、おかげで彼のデータソースをrelaoadする方法。