简体   繁体   English

jQuery Datatables按钮显示为链接..不是按钮

[英]jQuery Datatables buttons showing as links.. not buttons

Using jQuery DataTables 1.10.15 and I am trying to use the file export options. 使用jQuery DataTables 1.10.15 ,我正在尝试使用文件导出选项。

Here is how my scripts are loaded on the page: 这是我的脚本在页面上的加载方式:

<script src="/Scripts/DataTables/jquery.dataTables.js"></script>
<script src="/Scripts/DataTables/dataTables.bootstrap.js"></script>
<script src="/Scripts/DataTables/dataTables.buttons.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.3.1/js/buttons.flash.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script src="https://cdn.rawgit.com/bpampuch/pdfmake/0.1.27/build/pdfmake.min.js"></script>
<script src="https://cdn.rawgit.com/bpampuch/pdfmake/0.1.27/build/vfs_fonts.js"></script>
<script src="https://cdn.datatables.net/buttons/1.3.1/js/buttons.html5.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.3.1/js/buttons.print.min.js"></script>

Here is my DataTable setup: 这是我的数据表设置:

var table = $('#NewTable').DataTable({
    dom: 'Bfrtip',
    buttons: [ 'excel', 'pdf' ],
    'aoColumnDefs': [
        { "bSortable": false, "aTargets": [2, 7] },
        { "bSearchable": false, "aTargets": [7] }
    ]
});

Here is how they appear: 它们的外观如下:

在此处输入图片说明

How do I get them to appear as buttons and not links? 如何使它们显示为按钮而不是链接?

You're most likely missing the proper css file. 您很可能会丢失正确的CSS文件。

Try adding this css link (from CDN) to your header. 尝试将此CSS链接(来自CDN)添加到标题中。

https://cdn.datatables.net/buttons/1.3.1/css/buttons.dataTables.min.css

Working example: 工作示例:

 var table = $('#NewTable').DataTable({ dom: 'Bfrtip', buttons: [ 'excel', 'pdf' ], 'aoColumnDefs': [ { "bSortable": false, "aTargets": [2, 7] }, { "bSearchable": false, "aTargets": [7] } ] }); 
 <link href="https://cdn.datatables.net/buttons/1.3.1/css/buttons.dataTables.min.css" rel="stylesheet"/> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <script src="https://cdn.datatables.net/buttons/1.3.1/js/dataTables.buttons.min.js"></script> <script src="https://cdn.datatables.net/buttons/1.3.1/js/buttons.flash.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script> <script src="https://cdn.rawgit.com/bpampuch/pdfmake/0.1.27/build/pdfmake.min.js"></script> <script src="https://cdn.rawgit.com/bpampuch/pdfmake/0.1.27/build/vfs_fonts.js"></script> <script src="https://cdn.datatables.net/buttons/1.3.1/js/buttons.html5.min.js"></script> <script src="https://cdn.datatables.net/buttons/1.3.1/js/buttons.print.min.js"></script> <table id="NewTable"></table> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM