我已将此JavaScript if语句添加到我的MVC 5项目中,但是这不会将表工具添加到页面中,我也没有控制台错误。
if ($(".table").hasClass("ExportDataTable")) {
$('.table').dataTable({
"columnDefs": [
{ "type": "date", "targets": 0 }
],
"order": [[0, "desc"]],
responsive: true,
"dom": 'T<"clear">lfrtip',
"oTableTools": {
"sSwfPath": "http://cdn.datatables.net/tabletools/2.2.2/swf/copy_csv_xls.swf",
}
});
}
else {
$('.table').dataTable({
"columnDefs": [
{ "type": "date", "targets": 0 }
],
"order": [[0, "desc"]],
responsive: true
});
}