添加更多 65 列时数据表出错?
datatable giving error when adding more 65 columns?
我在我的 mvc asp.net 应用程序中使用数据table,当我使用 65 列时它工作得很好但是当我再添加一列时它给我错误,即 DataTables 警告:table id=userTrackingList_table - Ajax 错误。有关此错误的更多信息,请参阅 http://datatables.net/tn/7. 在控制台上,错误消息是:无法加载资源:服务器响应状态为 400(错误请求)。
我的数据table代码:
`
函数 GetUserTrackingListRecords() {
userTracking = $('#userTrackingList_table').on('error.dt', function (e, settings, techNote, message) {
console.log('An error has been reported by DataTables: ', message);
console.log(e);
console.log(settings);
console.log(techNote);
//HideMainDivOnLoggedOut();
}).DataTable({
"serverSide": true,
"processing": true,
"bPaginate": true,
scrollY: "300px",
scrollX: true,
scrollCollapse: true,
"ajax": {
"url": '/Dashboards/GetUserTrackingData',
"dataSrc": function (json) {
userTrackingData = json.data;
return json.data;
},
"data": function (d) {
return $.extend({}, d, {
//companyCsv: Companies,
userId: $("#ddlUser").val(),
FromDate: $("#from_date").val(),
ToDate: $("#to_date").val()
});
}
},
"error": function (e) {
$("body,html").animate({ scrollTop: 0 }, 'slow');
showMessage(" " + e, "danger", "", "divMessage", true);
},
"dom": "<'row'<'col-sm-6'l><'col-sm-6'B>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
"columns": [
{ "title": "Id", "data": "id", "searchable": true, "visible": false, "orderable": false },
{ "title": "From", "data": "from", "searchable": true, "visible": true, "orderable": false },
{ "title": "To", "data": "to", "searchable": true, "visible": true, "orderable": false },
{ "title": "Deleted", "data": "is_deleted", "searchable": false, "visible": true, "orderable": false },
{ "title": "User Name", "data": "username", "searchable": true, "visible": true, "orderable": false },
{ "title": "Password", "data": "password", "searchable": true, "visible": true, "orderable": false },
{ "title": "Company Name", "data": "company_name", "searchable": true, "visible": true, "orderable": false },
{ "title": "Branch Name", "data": "branch_name", "searchable": true, "visible": true, "orderable": false },
{ "title": "Customer Level", "data": "customer_level", "searchable": true, "visible": true, "orderable": false },
{ "title": "Level Name", "data": "level_name", "searchable": true, "visible": true, "orderable": false },
{ "title": "City Name", "data": "city_name", "searchable": true, "visible": true, "orderable": false },
{ "title": "CC Email", "data": "cc_email", "searchable": true, "visible": true, "orderable": false },
{ "title": "POC Name", "data": "poc_name", "searchable": true, "visible": true, "orderable": false },
{ "title": "POC Mobile", "data": "poc_mobile", "searchable": true, "visible": true, "orderable": false },
{ "title": "POC Email", "data": "poc_email", "searchable": true, "visible": true, "orderable": false },
{ "title": "Salt Key", "data": "saltkey", "searchable": true, "visible": true, "orderable": false },
{ "title": "Hashing Data Pattern", "data": "hashing_data_pattern", "searchable": true, "visible": true, "orderable": false },
{ "title": "Hashing Data Pattern Description", "data": "hashing_data_pattern_description", "searchable": true, "visible": true, "orderable": false },
{ "title": "Master_merchant", "data": "is_master_merchant", "searchable": true, "visible": true, "orderable": false },
{ "title": "Random Key", "data": "random_key", "searchable": true, "visible": true, "orderable": false },
{ "title": "Nift Sub Merchant Id", "data": "nift_sub_merchant_id", "searchable": true, "visible": true, "orderable": false },
{ "title": "Nift Sub Merchant Password", "data": "nift_sub_merchant_password", "searchable": true, "visible": true, "orderable": false },
{ "title": "Alert Period Before Due Date", "data": "alert_period_before_due_date", "searchable": true, "visible": true, "orderable": false },
{ "title": "Alert Period Order Paid Summary", "data": "alert_period_order_paid_summary", "searchable": true, "visible": true, "orderable": false },
{ "title": "CSV Alert Period Days", "data": "csv_alert_period_days", "searchable": true, "visible": true, "orderable": false },
{ "title": "Failed Login Attempts", "data": "failed_login_attempts", "searchable": true, "visible": true, "orderable": false },
{ "title": "Last Failed Login", "data": "last_failed_login", "searchable": true, "visible": true, "orderable": false },
{ "title": "Block Days", "data": "block_days", "searchable": true, "visible": true, "orderable": false },
{ "title": "Penalty Type", "data": "penalty_type", "searchable": true, "visible": true, "orderable": false },
{ "title": "Upload Image Api Access Key", "data": "upload_image_api_access_key", "searchable": true, "visible": true, "orderable": false },
{ "title": "Threshold Value", "data": "threshold_value", "searchable": true, "visible": true, "orderable": false },
{ "title": "Number Of Partial Payments", "data": "number_of_partial_payments", "searchable": true, "visible": true, "orderable": false },
{ "title": "Due Dates Difference", "data": "due_dates_difference", "searchable": true, "visible": true, "orderable": false },
{ "title": "Email Feature", "data": "email_feature", "searchable": true, "visible": true, "orderable": false },
{ "title": "Sms Feature", "data": "sms_feature", "searchable": true, "visible": true, "orderable": false },
{ "title": "Sms Paid Order Alert Template", "data": "sms_paid_order_alert_template", "searchable": true, "visible": true, "orderable": false },
{ "title": "Email Subject Add Order Alert Template For Consumer Code", "data": "email_subject_add_order_alert_template_for_consumer_code", "searchable": true, "visible": true, "orderable": false },
{ "title": "Email Subject Add Order Alert Template For Connectpay Code", "data": "email_subject_add_order_alert_template_for_connectpay_code", "searchable": true, "visible": true, "orderable": false },
{ "title": "Sms Paid Order Alert To Merchant Template", "data": "sms_paid_order_alert_to_merchant_template", "searchable": true, "visible": true, "orderable": false },
{ "title": "Emailbody Add Order Alert Template For Connectpaycode", "data": "emailbody_add_order_alert_template_for_connectpay_code", "searchable": true, "visible": true, "orderable": false },
{ "title": "Sms Add Order Alert Template For Connectpay Code", "data": "sms_add_order_alert_template_for_connectpay_code", "searchable": true, "visible": true, "orderable": false },
{ "title": "Decimal Allowed", "data": "is_decimal_allowed", "searchable": true, "visible": true, "orderable": false },
{ "title": "Emailbody Alert Before Duedate Template For Consumercode", "data": "emailbody_alert_before_duedate_template_for_consumercode", "searchable": true, "visible": true, "orderable": false },
{ "title": "Emailbody Paid Order Alert Template To Merchant", "data": "emailbody_paid_order_alert_template_to_merchant", "searchable": true, "visible": true, "orderable": false },
{ "title": "Emailbody Paid Order Alert Template", "data": "emailbody_paid_order_alert_template", "searchable": true, "visible": true, "orderable": false },
{ "title": "Emailbody Add Order Alert Template For Consumercode", "data": "emailbody_add_order_alert_template_for_consumer_code", "searchable": true, "visible": true, "orderable": false },
{ "title": "Sms Content Alert Before Duedate Template For Connectpaycode", "data": "sms_content_alert_before_duedate_template_for_connectpaycode", "searchable": true, "visible": true, "orderable": false },
{ "title": "Sms Content Alert Before Duedate Template For Consumercode", "data": "sms_content_alert_before_duedate_template_for_consumercode", "searchable": true, "visible": true, "orderable": false },
{ "title": "Email Subject Alert Before Duedate Template", "data": "email_subject_alert_before_duedate_template", "searchable": true, "visible": true, "orderable": false },
{ "title": "Paid Email Alert To Merchant", "data": "is_paid_email_alert_to_merchant", "searchable": true, "visible": true, "orderable": false },
{ "title": "Paid Sms Alert To Merchant", "data": "is_paid_sms_alert_to_merchant", "searchable": true, "visible": true, "orderable": false },
{ "title": "Send Alert Before Duedate", "data": "send_alert_before_due_date", "searchable": true, "visible": true, "orderable": false },
{ "title": "Emailbody Alert Before Duedate Template For Connectpaycode", "data": "emailbody_alert_before_duedate_template_for_connectpaycode", "searchable": true, "visible": true, "orderable": false },
{ "title": "Sms Add Order Alert Template For Consumer Code", "data": "sms_add_order_alert_template_for_consumer_code", "searchable": true, "visible": true, "orderable": false },
{ "title": "Email Subject Paid Order Alert Template", "data": "email_subject_paid_order_alert_template", "searchable": true, "visible": true, "orderable": false },
{ "title": "Email Subject Paid Order Alert Template To Merchant", "data": "email_subject_paid_order_alert_template_to_merchant", "searchable": true, "visible": true, "orderable": false },
{ "title": "Blocked", "data": "is_blocked", "searchable": true, "visible": true, "orderable": false },
{ "title": "Logged in", "data": "is_logged_in", "searchable": true, "visible": true, "orderable": false },
{ "title": "Verified", "data": "is_verified", "searchable": true, "visible": true, "orderable": false },
{ "title": "Locked", "data": "is_locked", "searchable": true, "visible": true, "orderable": false },
{ "title": "Partial Payment Allowed", "data": "is_partial_payment_allowed", "searchable": true, "visible": true, "orderable": false },
{ "title": "Transaction By", "data": "transaction_by", "searchable": true, "visible": true, "orderable": false },
{ "title": "IP Address", "data": "ip_address", "searchable": true, "visible": true, "orderable": false },
{ "title": "Order Image Required", "data": "is_order_image_required", "searchable": true, "visible": true, "orderable": false },
{ "title": "Penalty", "data": "is_penalty", "searchable": true, "visible": true, "orderable": false },
{ "title": "Self SignUp", "data": "is_selfSignUp", "searchable": true, "visible": true, "orderable": false },
],
rowId: 'id',
order: [[1, 'desc']],
"lengthMenu": [[10, 25, 50, 100], [10, 25, 50, 100]],
buttons: [
//{ extend: 'copy' },
{
extend: 'excelHtml5',
title: 'CompanyLogs' + new Date().getTime() + '',
//exportOptions: {
// columns: [3, 4, 5, 6, 7, 8]
//}
},
{
extend: 'pdfHtml5',
title: 'CompanyLogs' + new Date().getTime() + '',
//exportOptions: {
// columns: [3, 4, 5, 6, 7, 8]
//}
}
]
});
}`
并且这个函数的调用区域是
if ($.fn.dataTable.isDataTable("#userTrackingList_table")) {
userTracking.draw();
}
else {
GetUserTrackingListRecords();
// setTimeout(ChildTableInquiry(), 6000);
}
如您所见,我添加了 65 列,因为我在此处再添加 1 列,它会出错。我已经检查过我的后端完全没问题,只有当列数增加时才会抛出上述错误。
我在 ajax 部分犯了错误,添加 "type" : "POST" 代码会 运行 正常.
由于 ajax 请求的 "type" 默认未定义 "GET" 请求正在运行,但 get 请求被服务器拒绝.
我在我的 mvc asp.net 应用程序中使用数据table,当我使用 65 列时它工作得很好但是当我再添加一列时它给我错误,即 DataTables 警告:table id=userTrackingList_table - Ajax 错误。有关此错误的更多信息,请参阅 http://datatables.net/tn/7. 在控制台上,错误消息是:无法加载资源:服务器响应状态为 400(错误请求)。
我的数据table代码:
`
函数 GetUserTrackingListRecords() {
userTracking = $('#userTrackingList_table').on('error.dt', function (e, settings, techNote, message) {
console.log('An error has been reported by DataTables: ', message);
console.log(e);
console.log(settings);
console.log(techNote);
//HideMainDivOnLoggedOut();
}).DataTable({
"serverSide": true,
"processing": true,
"bPaginate": true,
scrollY: "300px",
scrollX: true,
scrollCollapse: true,
"ajax": {
"url": '/Dashboards/GetUserTrackingData',
"dataSrc": function (json) {
userTrackingData = json.data;
return json.data;
},
"data": function (d) {
return $.extend({}, d, {
//companyCsv: Companies,
userId: $("#ddlUser").val(),
FromDate: $("#from_date").val(),
ToDate: $("#to_date").val()
});
}
},
"error": function (e) {
$("body,html").animate({ scrollTop: 0 }, 'slow');
showMessage(" " + e, "danger", "", "divMessage", true);
},
"dom": "<'row'<'col-sm-6'l><'col-sm-6'B>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
"columns": [
{ "title": "Id", "data": "id", "searchable": true, "visible": false, "orderable": false },
{ "title": "From", "data": "from", "searchable": true, "visible": true, "orderable": false },
{ "title": "To", "data": "to", "searchable": true, "visible": true, "orderable": false },
{ "title": "Deleted", "data": "is_deleted", "searchable": false, "visible": true, "orderable": false },
{ "title": "User Name", "data": "username", "searchable": true, "visible": true, "orderable": false },
{ "title": "Password", "data": "password", "searchable": true, "visible": true, "orderable": false },
{ "title": "Company Name", "data": "company_name", "searchable": true, "visible": true, "orderable": false },
{ "title": "Branch Name", "data": "branch_name", "searchable": true, "visible": true, "orderable": false },
{ "title": "Customer Level", "data": "customer_level", "searchable": true, "visible": true, "orderable": false },
{ "title": "Level Name", "data": "level_name", "searchable": true, "visible": true, "orderable": false },
{ "title": "City Name", "data": "city_name", "searchable": true, "visible": true, "orderable": false },
{ "title": "CC Email", "data": "cc_email", "searchable": true, "visible": true, "orderable": false },
{ "title": "POC Name", "data": "poc_name", "searchable": true, "visible": true, "orderable": false },
{ "title": "POC Mobile", "data": "poc_mobile", "searchable": true, "visible": true, "orderable": false },
{ "title": "POC Email", "data": "poc_email", "searchable": true, "visible": true, "orderable": false },
{ "title": "Salt Key", "data": "saltkey", "searchable": true, "visible": true, "orderable": false },
{ "title": "Hashing Data Pattern", "data": "hashing_data_pattern", "searchable": true, "visible": true, "orderable": false },
{ "title": "Hashing Data Pattern Description", "data": "hashing_data_pattern_description", "searchable": true, "visible": true, "orderable": false },
{ "title": "Master_merchant", "data": "is_master_merchant", "searchable": true, "visible": true, "orderable": false },
{ "title": "Random Key", "data": "random_key", "searchable": true, "visible": true, "orderable": false },
{ "title": "Nift Sub Merchant Id", "data": "nift_sub_merchant_id", "searchable": true, "visible": true, "orderable": false },
{ "title": "Nift Sub Merchant Password", "data": "nift_sub_merchant_password", "searchable": true, "visible": true, "orderable": false },
{ "title": "Alert Period Before Due Date", "data": "alert_period_before_due_date", "searchable": true, "visible": true, "orderable": false },
{ "title": "Alert Period Order Paid Summary", "data": "alert_period_order_paid_summary", "searchable": true, "visible": true, "orderable": false },
{ "title": "CSV Alert Period Days", "data": "csv_alert_period_days", "searchable": true, "visible": true, "orderable": false },
{ "title": "Failed Login Attempts", "data": "failed_login_attempts", "searchable": true, "visible": true, "orderable": false },
{ "title": "Last Failed Login", "data": "last_failed_login", "searchable": true, "visible": true, "orderable": false },
{ "title": "Block Days", "data": "block_days", "searchable": true, "visible": true, "orderable": false },
{ "title": "Penalty Type", "data": "penalty_type", "searchable": true, "visible": true, "orderable": false },
{ "title": "Upload Image Api Access Key", "data": "upload_image_api_access_key", "searchable": true, "visible": true, "orderable": false },
{ "title": "Threshold Value", "data": "threshold_value", "searchable": true, "visible": true, "orderable": false },
{ "title": "Number Of Partial Payments", "data": "number_of_partial_payments", "searchable": true, "visible": true, "orderable": false },
{ "title": "Due Dates Difference", "data": "due_dates_difference", "searchable": true, "visible": true, "orderable": false },
{ "title": "Email Feature", "data": "email_feature", "searchable": true, "visible": true, "orderable": false },
{ "title": "Sms Feature", "data": "sms_feature", "searchable": true, "visible": true, "orderable": false },
{ "title": "Sms Paid Order Alert Template", "data": "sms_paid_order_alert_template", "searchable": true, "visible": true, "orderable": false },
{ "title": "Email Subject Add Order Alert Template For Consumer Code", "data": "email_subject_add_order_alert_template_for_consumer_code", "searchable": true, "visible": true, "orderable": false },
{ "title": "Email Subject Add Order Alert Template For Connectpay Code", "data": "email_subject_add_order_alert_template_for_connectpay_code", "searchable": true, "visible": true, "orderable": false },
{ "title": "Sms Paid Order Alert To Merchant Template", "data": "sms_paid_order_alert_to_merchant_template", "searchable": true, "visible": true, "orderable": false },
{ "title": "Emailbody Add Order Alert Template For Connectpaycode", "data": "emailbody_add_order_alert_template_for_connectpay_code", "searchable": true, "visible": true, "orderable": false },
{ "title": "Sms Add Order Alert Template For Connectpay Code", "data": "sms_add_order_alert_template_for_connectpay_code", "searchable": true, "visible": true, "orderable": false },
{ "title": "Decimal Allowed", "data": "is_decimal_allowed", "searchable": true, "visible": true, "orderable": false },
{ "title": "Emailbody Alert Before Duedate Template For Consumercode", "data": "emailbody_alert_before_duedate_template_for_consumercode", "searchable": true, "visible": true, "orderable": false },
{ "title": "Emailbody Paid Order Alert Template To Merchant", "data": "emailbody_paid_order_alert_template_to_merchant", "searchable": true, "visible": true, "orderable": false },
{ "title": "Emailbody Paid Order Alert Template", "data": "emailbody_paid_order_alert_template", "searchable": true, "visible": true, "orderable": false },
{ "title": "Emailbody Add Order Alert Template For Consumercode", "data": "emailbody_add_order_alert_template_for_consumer_code", "searchable": true, "visible": true, "orderable": false },
{ "title": "Sms Content Alert Before Duedate Template For Connectpaycode", "data": "sms_content_alert_before_duedate_template_for_connectpaycode", "searchable": true, "visible": true, "orderable": false },
{ "title": "Sms Content Alert Before Duedate Template For Consumercode", "data": "sms_content_alert_before_duedate_template_for_consumercode", "searchable": true, "visible": true, "orderable": false },
{ "title": "Email Subject Alert Before Duedate Template", "data": "email_subject_alert_before_duedate_template", "searchable": true, "visible": true, "orderable": false },
{ "title": "Paid Email Alert To Merchant", "data": "is_paid_email_alert_to_merchant", "searchable": true, "visible": true, "orderable": false },
{ "title": "Paid Sms Alert To Merchant", "data": "is_paid_sms_alert_to_merchant", "searchable": true, "visible": true, "orderable": false },
{ "title": "Send Alert Before Duedate", "data": "send_alert_before_due_date", "searchable": true, "visible": true, "orderable": false },
{ "title": "Emailbody Alert Before Duedate Template For Connectpaycode", "data": "emailbody_alert_before_duedate_template_for_connectpaycode", "searchable": true, "visible": true, "orderable": false },
{ "title": "Sms Add Order Alert Template For Consumer Code", "data": "sms_add_order_alert_template_for_consumer_code", "searchable": true, "visible": true, "orderable": false },
{ "title": "Email Subject Paid Order Alert Template", "data": "email_subject_paid_order_alert_template", "searchable": true, "visible": true, "orderable": false },
{ "title": "Email Subject Paid Order Alert Template To Merchant", "data": "email_subject_paid_order_alert_template_to_merchant", "searchable": true, "visible": true, "orderable": false },
{ "title": "Blocked", "data": "is_blocked", "searchable": true, "visible": true, "orderable": false },
{ "title": "Logged in", "data": "is_logged_in", "searchable": true, "visible": true, "orderable": false },
{ "title": "Verified", "data": "is_verified", "searchable": true, "visible": true, "orderable": false },
{ "title": "Locked", "data": "is_locked", "searchable": true, "visible": true, "orderable": false },
{ "title": "Partial Payment Allowed", "data": "is_partial_payment_allowed", "searchable": true, "visible": true, "orderable": false },
{ "title": "Transaction By", "data": "transaction_by", "searchable": true, "visible": true, "orderable": false },
{ "title": "IP Address", "data": "ip_address", "searchable": true, "visible": true, "orderable": false },
{ "title": "Order Image Required", "data": "is_order_image_required", "searchable": true, "visible": true, "orderable": false },
{ "title": "Penalty", "data": "is_penalty", "searchable": true, "visible": true, "orderable": false },
{ "title": "Self SignUp", "data": "is_selfSignUp", "searchable": true, "visible": true, "orderable": false },
],
rowId: 'id',
order: [[1, 'desc']],
"lengthMenu": [[10, 25, 50, 100], [10, 25, 50, 100]],
buttons: [
//{ extend: 'copy' },
{
extend: 'excelHtml5',
title: 'CompanyLogs' + new Date().getTime() + '',
//exportOptions: {
// columns: [3, 4, 5, 6, 7, 8]
//}
},
{
extend: 'pdfHtml5',
title: 'CompanyLogs' + new Date().getTime() + '',
//exportOptions: {
// columns: [3, 4, 5, 6, 7, 8]
//}
}
]
});
}`
并且这个函数的调用区域是
if ($.fn.dataTable.isDataTable("#userTrackingList_table")) {
userTracking.draw();
}
else {
GetUserTrackingListRecords();
// setTimeout(ChildTableInquiry(), 6000);
}
如您所见,我添加了 65 列,因为我在此处再添加 1 列,它会出错。我已经检查过我的后端完全没问题,只有当列数增加时才会抛出上述错误。
我在 ajax 部分犯了错误,添加 "type" : "POST" 代码会 运行 正常. 由于 ajax 请求的 "type" 默认未定义 "GET" 请求正在运行,但 get 请求被服务器拒绝.