jquery datatable excel导出按钮不显示 [英] jquery datatable excel export button not showing

查看:2992
本文介绍了jquery datatable excel导出按钮不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Datatables js版本 1.9.4 css版本 1.9.4 。并使用以下代码初始化数据表。

Hi i'm using Datatables js version 1.9.4 css version 1.9.4. And initialize the data table using below code.

还添加了支持js和css

Also added support js and css

<script type="text/javascript" th:src="@{/resources/js/excel-export/dataTables.buttons.min.js}"></script>
<script type="text/javascript" th:src="@{/resources/js/excel-export/buttons.flash.min.js}"></script>
<script type="text/javascript" th:src="@{/resources/js/excel-export/jszip.min.js}"></script>
<script type="text/javascript" th:src="@{/resources/js/excel-export/buttons.html5.min.js}"></script>
<script type="text/javascript" th:src="@{/resources/js/excel-export/buttons.print.min.js}"></script>
<link th:href="@{/resources/js/excel-export/buttons.dataTables.min.css}"
    type="text/css" rel="stylesheet" />

var tblUnSubscribedKeys = $('#tblUnSubscribedKeys').DataTable({
                     "aoColumns" : [ null, null,null,null,null,null],
                     "processing": true,
                     "serverSide": true,
                     dom: 'Bfrtip',
                           buttons: [
                               'excel'
                           ]
                 });

问题是,表上的数据填充正确。但是excel导出按钮是不可见的。

The problem is, the data on the table populated correctly. But the excel export button is not visible.

推荐答案

您似乎使用按钮配置 datatables 1.10

Datatables 1.9

这是一个过去使用的一些代码显示CSV按钮:

Here's a bit of code I've used in the past to show CSV buttons:

"sDom": 'T<"clear">lfrtip',
"oTableTools": {
            "aButtons" : [
                {
                    "sExtends" : "csv",
                    "sButtonText" : "Download Excel"
                },
                {
                    "sExtends" : "pdf",
                    "sButtonText" : "Download PDF",
                    "sPdfOrientation": "landscape"
                }
            ],
            "sSwfPath": "/swf/copy_csv_xls_pdf.swf"
        },

我,但你应该检查文档,并适应你认为合适。
希望有帮助!

That worked for me, but you should check the docs and adapt it as you see fit. Hope it helps!

这篇关于jquery datatable excel导出按钮不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆