2017-02-14 86 views
0

是否有可能有一個動畫加載文本/旋轉時加載數據到我的數據表也爲我的刪除列是否可以顯示確認彈出?Datatable ajax刪除確認彈出&加載消息

$(document).ready(function() { 
      $('#ProvTable').DataTable({ 
      "ajax": { 
       "url": "/Users/Prov", 
       "type": "Get", 
       "data": { "idUser": "@userid", "idCity": "@cityId" }, 
       "datatype": "json" 

      }, 

      "columns": [ 
       { "data": "Id", "visible": false, "searchable": false }, 
       { "data": "Name", "autowidth": true }, 
       { "data": "City", "autowidth": true }, 
       { "data": "UID", "autowidth": true }, 
       { 
        "title": "Delete", 
        "data": "Id", 
        "searchable": false, 
        "sortable": false, 
        "render": function (data, type, full, meta) { 
         return '<a href="@Url.Action("Delete", "Users")?id=' + data + '" class="editUser"><span class="glyphicon glyphicon-trash btn-sm btn-danger"></span></a>'; 
        } 
       }, 
      ] 


     }); 
+0

是的,你可以顯示刪除操作的確認彈出 –

+0

是的,這顯然是可能。閱讀[這個SO帖子](http://stackoverflow.com/questions/1964839/how-can-i-create-a-please-wait-loading-animation-using-jquery)瞭解如何創建一個加載使用jQuery的動畫。對於彈出使用[jQuery對話框](https://jqueryui.com/dialog/) – ViVi

回答

0

這是你如何顯示在數據庫中的一個確認對話框

$(document).ready(function() { 
    var provTable=$('#ProvTable').DataTable({ 
     "ajax": { 
      "url": "/Users/Prov", 
      "type": "Get", 
      "data": { "idUser": "@userid", "idCity": "@cityId" }, 
      "datatype": "json" 

     }, 

     "columns": [ 
      { "data": "Id", "visible": false, "searchable": false }, 
      { "data": "Name", "autowidth": true }, 
      { "data": "City", "autowidth": true }, 
      { "data": "UID", "autowidth": true }, 
      { 
        data: null, 
        orderable: false, 
        className: "dt-center", 
        defaultContent: ' <a href="#" id=del>Delete</a>' 

      }, 
     ] 


    }); 

    $('#ProvTable tbody').on('click', 'tr td #del', function() { 
     var row = $(this).parents('tr')[0]; 
     var mydata = (provTable.row(row).data()); 
     var con=confirm("Are you sure you want to delet this "+ mydata["Id"]) 
    if(con){ 
      // Do Something 
    } 
    else 
     { 
     // Nothing to do here 
     } 
}); 

    }); 

您將在邁德特得到全行數據