如何克服此弹出错误“ DataTables警告:表id = DataTables_Table_0-无法重新初始化DataTable。有关此错误的更多信息,请参见http://datatables.net/tn/3”
另外,我想居中对齐表格该怎么做?
我已经尝试过datatables网站上提供的方法,但无法解决任何问题 如果我忽略此错误会发生什么?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>UIT-RGPV</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<body>
<div class="container" style="margin-top: 30px">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<table class="table table-bordered table-hover" style="width:100%">
<thead>
<tr>
<td>ID</td>
<td>Alloted Room</td>
</tr>
</thead>
<tbody>
<?php
$conn = new mysqli('localhost', 'root', '', 'data');
$sql = $conn->query('SELECT * FROM user');
while($data = $sql->fetch_array()) {
echo '
<tr>
<td>'.$data['id'].'</td>
<td>'.$data['fname'].'</td>
</tr>
';
}
?>
</tbody>
</table>
</div>
</div>
</div>
<script src="js/jquery-3.4.1.min.js"></script>
<script src="js/jquery.dataTables.js"></script>
<script src="js/dataTables.bootstrap.js"></script>
<script>
$(".table").DataTable();
</script>
<script type="text/javascript">
$(document).ready(function() {
$(".table").DataTable({
"ordering": true,
"searching": true,
"paging": true,
"columnDefs": [
{
"targets": 0,
"searchable": false,
"visible": true
}
],
"order": [[2, "desc"]]
});
});
</script>
</body>
</html>
我想使中心对齐表,但它在左侧对齐,并且我想克服该弹出错误。
答案 0 :(得分:0)
删除
#define BOOST_TEST_MODULE My Test
#include <boost/test/included/unit_test.hpp>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <set>
BOOST_AUTO_TEST_CASE(TEST) {
std::vector<std::string> devices{
"tty1",
"ttyOfk",
"ttyS05",
"bsd",
}, ports{};
const std::set<std::string> comport_keys{
"ttyS",
"ttyO",
"ttyUSB",
"ttyACM",
"ttyGS",
"ttyMI",
"ttymxc",
"ttyAMA",
"ttyTHS",
"ircomm",
"rfcomm",
"tnt",
"cu",
"ser",
};
std::sort(devices.begin(), devices.end());
std::set_intersection(devices.cbegin(), devices.cend(),
comport_keys.cbegin(), comport_keys.cend(),
std::back_inserter(ports),
[&comport_keys] (auto a, auto b) {
return a.find(b) != std::string::npos; //This is wrong
});
const std::vector<std::string>test_set {
"ttyOfk",
"ttyS05",
};
BOOST_TEST(ports == test_set);
}
从代码中并将{
"Type": "Name",
"parameters": [
{
"A": {
"type": "string",
"defaultValue": "key"
},
"B": {
"type": "string",
"defaultValue": "key"
},
"C": {
"type": "string",
"defaultValue": "key"
},
"D": {
"type": "string",
"defaultValue": "autogenerated"
},
"E": {
"type": "string",
"defaultValue": "autogenerated"
},
"F": {
"type": "dropdown",
"dropDownItems": [
"true",
"false"
],
"defaultValue": "false"
}
}
]
}
添加到表格中以使表格位于页面中心,如果您需要将内容居中对齐,则表示<script>
$(".table").DataTable();
</script>
,如果两者都位于页面中央表示只使用style="margin: 0 auto;"