[英]How to get delete button name from datatable for a modal confirm delete
我正在尝试制作一个模态弹出窗口(使用 Bootstrap)来确认删除此数据表中的一行。
我将如何调用此数据表中的删除功能,以便我可以告诉我的模态弹出以确认删除?
我不确定这是否有意义,但我希望在这里继续下去就足够了。
$(document).ready(function () {
$('#Test1').DataTable({
"processing": true,
"serverSide": true,
"ajax": {
url: "@Url.Action("LoadData", "Test1")",
type: 'POST'
},
"columns": [
{"data": 'Test2'},
{"data": 'Test3'},
{"data": 'Test4'},
{"data": 'Test5'},
{"data": 'Test6'},
{"data": 'Test7'},
{"data": 'Actions',
"render": function(data, type, row, meta) {
return "<a href = '@Url.Action("Edit", "Test1")?companyId=" + row.CompanyID + "&profileId=" + row.ProfileID + "&clientId=" + row.ClientID+ "' title = \"Edit\"><i class='icon-edit fa fa-pencil fa-fw fa-lg'></i></a>" +
"<a href='@Url.Action("Copy", "CopyTest1")?companyId=" + row.CompanyID + "&profileId=" + row.ProfileID + "&clientId=" + row.ClientID+ "' title=\"Duplicate\"><i class='icon-replicate fa fa-clipboard fa-fw fa-lg'></i></a>" +
"<a href='@Url.Action("Delete", "Test1")?companyId=" + row.CompanyID + "&profileId=" + row.ProfileID + "&clientId=" + row.ClientID+ "' title=\"Delete\"><i class='icon-red fa fa-times fa-lg fa-fw'></i></a>" ;
}
}
],
"columnDefs": [ {
"targets": [-1],
"orderable": false,
"searchable": false
} ]
});
console.log("ready to work");
});
或者你可以使用 JavaScript Window confirm() Method
。
$(document).ready(function () {
$('#Test1').DataTable({
"processing": true,
"serverSide": true,
"ajax": {
url: "@Url.Action("LoadData", "Test1")",
type: 'POST'
},
"columns": [
{"data": 'Test2'},
{"data": 'Test3'},
{"data": 'Test4'},
{"data": 'Test5'},
{"data": 'Test6'},
{"data": 'Test7'},
{"data": 'Actions',
"render": function(data, type, row, meta) {
return "<a href = '@Url.Action("Edit", "Test1")?companyId=" + row.CompanyID + "&profileId=" + row.ProfileID + "&clientId=" + row.ClientID+ "' title = \"Edit\"><i class='icon-edit fa fa-pencil fa-fw fa-lg'></i></a>" +
"<a href='@Url.Action("Copy", "CopyTest1")?companyId=" + row.CompanyID + "&profileId=" + row.ProfileID + "&clientId=" + row.ClientID+ "' title=\"Duplicate\"><i class='icon-replicate fa fa-clipboard fa-fw fa-lg'></i></a>" +
"<a href='@Url.Action("Delete", "Test1")?companyId=" + row.CompanyID + "&profileId=" + row.ProfileID + "&clientId=" + row.ClientID+ "' title=\"Delete\" onclick=\"return ConfirmDelete()\"><i class='icon-red fa fa-times fa-lg fa-fw'></i></a>" ;
}
}
],
"columnDefs": [ {
"targets": [-1],
"orderable": false,
"searchable": false
} ]
});
console.log("ready to work");
function ConfirmDelete() {
if (confirm('Are you sure to delete this?')) {
return true;
}
else {
return false;
}
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.