Datatable ajax删除确认弹出窗口&加载消息

时间:2017-02-14 10:41:12

标签: jquery asp.net-mvc datatables

在将数据加载到我的数据表时,是否可以使用动画加载文本/旋转,对于我的删除列,是否可以显示确认弹出窗口?

$(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>';
                    }
               },
            ]


        });

1 个答案:

答案 0 :(得分: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
      }
});

  });

您将在MyData中获得整行数据