我这里有一个on click事件,它在jquery确认中显示表数据,但是datatable不会显示,即使只显示datatable也不能正常工作,它只显示普通表。你能告诉我为什么不起作用是什么问题。先感谢您。我将表放在jquery中,并创建一个datatable函数。
$(document).on('click','.btnNotifyRecom',function (){
var BranchCode = $(this).attr("id");
var TranNo = $(this).attr("data-value");
var TranType = $(this).attr("data-value1");
$.confirm({
title: 'Notify to Payroll Department',
content: '' +
'<form action="" class="formName">' +
'<div class="form-group">' +
'<label>Select Employee</label>' +
'<input class="form-control employees MySelect Content" placeholder="Enter ID/Name" list="employeename" id="EmployeeID" />'+
'<datalist id="employeename" class="EmployeeIDsubmit" style="width:10%"></datalist>'+
'</select>' +
'</div>' +
'</form>' +
'<table id="NotifyTable" class="table table-striped table-bordered table-sm cell-border compact stripe" style="width:100%; margin-top: 10px;"> '+
'<thead><tr><th>Employee</th><th>Notify Date</th></tr></thead>' +
' <tbody id="NotifyTable"></tbody>' +
'</table>',
buttons: {
formSubmit: {
text: 'Submit',
btnClass: 'btn-blue',
action: function () {
var Content = this.$content.find('.Content').val();
if (!Content) {
$.alert('Please Select Employee');
return false;
}
else {
$.ajax({
type: 'POST',
dataType: "json",
url: '@Url.Action("SubmitNotifyUser", "SummaryOBTOA")',
data: {
'TranNo': TranNo,
'BranchCode': BranchCode,
'TranType': TranType,
'Content': Content,
'Action': 'NotifyRecome',
}
});
$.alert('Employee Number: ' + Content + ' has been notified');
return false;
}
}
},
cancel: function () {
//close
},
},
onContentReady: function () {
// bind to events
var jc = this;
this.$content.find('form').on('submit', function (e) {
// if the user submits the form by pressing enter in the field.
e.preventDefault();
jc.$$formSubmit.trigger('click'); // reference the button and click it
});
}
});
$('#NotifyTable').DataTable({
"language": {
emptyTable: "No Transaction"
},
ajax: {
url: '@Url.Action("GetNotifyUsers", "SummaryOBTOA")',
data: {
'TranNo': TranNo,
'TranType': TranType,
'BranchCode': BranchCode,
'NotifyType': 'NotifyRecome',
},
dataType: "json",
retrieve: "true",
processing: "true",
serverSide: "true",
type: "POST",
dataSrc: "",
},
order: [],
columnDefs: [
{
targgets: [1],
orderable: false,
}
],
columns: [
{ data: "EmpName" },
{ data: "NotifyDate" }
]
});
});