Sunteți pe pagina 1din 2

<script type="text/javascript">

$(function () {

$(document).on('hidden.bs.modal','#edituser', function (e) {


oTable.draw();
$('#dldata').remove();
});

var oTable = $('#listusers').DataTable({


"aoColumnDefs": [{ 'bSortable': false, 'aTargets': [0,'nosort']
}],
"ajax":
{"url":"https://vertical.loannotify.com/vertical/dtquery/list_users","type":
"POST"},
responsive: true,
"processing": true,
"serverSide": true,
"paging": true,
"lengthChange": true,
"searching": true,
"ordering": true,
"info": true,
"autoWidth": false,
"language": {
"emptyTable": "User does not exist"
}
});

// Immediately remove the first row

$('.dataTable').on( "click",'.del_user', function(e) {


var id= $(this).attr('dt');

swal({
title: "Are you sure?",
text: "Your will not be able to recover this user
anymore!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, Delete Account",
cancelButtonText: "No, Cancel",
closeOnConfirm: false,
closeOnCancel: false },
function (isConfirm) {
if (isConfirm) {

$.post("https://vertical.loannotify.com/vertical/dtresponse/deleteuser",
{userid: id},function(data,status){
if(status == "success") {
//alert("Data: " + data +
"\nStatus: " + status);
swal("Deleted", "User Successfully
deleted", "success");

oTable.row('.selected').remove().draw(false);
}else {
alert("Error : Something went wrong
please try again.\nStatus : "+status);
}
});

} else {
swal("Cancelled", "Action cancelled", "error");
}
});
/* if (confirm("Do you really want to delete User's record?"))
{

} */
e.preventDefault();
});

$('.dataTable').on( "click",'.edit_user', function() {


$('.alert').remove();
//alert($(this).attr('dt'));

$.post( "https://vertical.loannotify.com/vertical/dtresponse/edit_user",{userid: $
(this).attr('dt')}, function(data,status) {
if(status == "success") {
var dls = '<div id="dldata">' + data + '</div>';
$(dls).appendTo('body');
// $("#dldata").html(data);
// alert( "Load was performed." );
}
});

});

$(document).on("click",'#refresh', function() {
oTable.draw();
});

});
</script>

S-ar putea să vă placă și