【发布时间】:2021-12-14 01:43:57
【问题描述】:
我有一个 php/javascript 应用程序(Windows 上的 Apache 2.4 / php8)。我正在使用 jquery DataTables (datatables.net) 并进行了编码:
dom: 'Brftip',
buttons: ['excel']
我的应用程序中的几个表。
当我在 javascript 中作为在另一个表中选择的结果动态构建表时,这非常有用。但是,当我在我的文档就绪功能中内置的表格中编写该按钮时,该按钮不会显示。下面是我的 $(document).ready() 函数的相关部分:
$(document).ready(function () {
$('#jobs').DataTable({
dom: 'Bfrtip',
buttons: ['excel'],
select: {
sytle: 'single',
items: 'row'
},
ajax: {
url: "php/joblist.php",
type: "POST",
dataSrc: "",
data: function (d) {
var activeOnlyCheckbox = document.getElementById("activeOnly");
if (activeOnlyCheckbox.checked) {
return JSON.stringify({activeOnly: 'yes'});
} else {
return JSON.stringify({activeOnly: 'no'});
}
}
},
paging: false,
scrollY: '60vh',
scrollCollapse: true,
columns: [
{data: "JOB_ID"},
{data: "LAST_START"},
{data: "LAST_FINISH"},
{data: "LAST_STATUS"}
],
"columnDefs": [{
"targets": 3,
"data": "LAST_STATUS",
"render": function (data, type, row, meta) {
if (screen.width > 1500) {
return "<div class='text-wrap status-column'>" + data + "</div>";
} else {
return "<div class='text-wrap status-column'>" + data + "</div>";
}
}
}]
});
});
我错过了什么?
【问题讨论】:
-
可能不是答案,但请注意,您有一个错字:
sytle: 'single',。应该是style: 'single',。
标签: javascript jquery datatables