[英]Datatables - Responsive not working?
I am trying to understand why Datatables ( https://datatables.net/ ) Responsive wouldn't be working.我试图了解为什么 Datatables ( https://datatables.net/ ) Responsive 不起作用。 Everything else is working great, paging, searching, ordering, etc.. but not responsive?
其他一切都很好,分页、搜索、排序等……但没有响应?
Below is what I have.下面是我所拥有的。
Bootstrap v3.3.6引导程序 v3.3.6
$(function () { $('#ManageUsers').DataTable({ paging: true, lengthChange: true, searching: true, ordering: true, info: true, autoWidth: true, responsive: true }); });
<!-- CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> <link rel="stylesheet" href="https://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css"> <!-- JS --> <script src="https://code.jquery.com/jquery-2.2.4.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <script src="https://cdn.datatables.net/1.10.8/js/jquery.dataTables.min.js"></script> <script src="https://cdn.datatables.net/1.10.8/js/dataTables.bootstrap.min.js"></script> <script src="https://cdn.datatables.net/responsive/2.1.0/js/dataTables.responsive.js"></script> <!-- CODE --> <table id="ManageUsers" class="table table-bordered table-striped display responsive"> <thead> <tr> <th>...</th> </tr> </thead> <tbody> <tr> <td>...</td> </tr> </tbody> </table>
Any help will be greatly appreciated.任何帮助将不胜感激。
Try loading the libraries in this order like in the DEMO . 尝试像在DEMO中那样按此顺序加载库。
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.js"></script>
<script data-require="datatables@*" data-semver="1.10.12" src="//cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.13/js/dataTables.bootstrap.min.js"></script>
<script src="https://cdn.datatables.net/responsive/2.1.0/js/dataTables.responsive.js"></script>
<link href="//cdn.datatables.net/responsive/2.1.1/css/dataTables.responsive.css"/>
<link data-require="datatables@*" data-semver="1.10.12" rel="stylesheet" href="//cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css" />
<link data-require="bootstrap@*" data-semver="4.0.5" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" />
Please refer to these links for reference https://datatables.net/extensions/responsive/examples/initialisation/default.html https://datatables.net/extensions/responsive/examples/initialisation/className.html https://datatables.net/extensions/responsive/examples/initialisation/option.html 请参考这些链接以获取参考https://datatables.net/extensions/sensitive/examples/initialisation/default.html https://datatables.net/extensions/sensitive/examples/initialisation/className.html https:// datatables达网络/扩展/响应/示例/初始化/ option.html
Try using width=100% in table. 尝试在表格中使用width = 100%。 Not pretty, but it worked for me.
不漂亮,但是对我有用。
Just use this script at the bottom of your file只需在文件底部使用此脚本
<script>
$(function () {
$("#manageUsers").DataTable({
"bLengthChange": false,
"bPaginate": true,
"bInfo": false,
"autoWidth": false,
"order": [[0, "desc"]],
responsive: true,
"processing": true,
"serverSide": false,
"sAjaxSource": "data.js",
"columns": [
{ "data": "name[, ]" },
{ "data": "hr.0" },
{ "data": "office" },
{ "data": "extn" },
{ "data": "hr.2" },
{ "data": "hr.1" }
});
</script>
It worked for me.它对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.