angularjs数据表按钮插件

时间:2015-10-29 12:05:33

标签: javascript jquery angularjs datatables

我使用angularjs数据表并尝试在此页面中使用按钮插件https://l-lin.github.io/angular-datatables/#/withButtons

.withButtons([
    'columnsToggle',
    'colvis',
    'copy',
    'pdf',
    'excel',
    {
        text: 'Some button',
        key: '1',
        action: function (e, dt, node, config) {
            alert('Button activated');
        }
    }
]);

我收到未知按钮类型:' columnsToggle'和' colvis' 但当我删除' columnsToggle'和' colvis'从代码运行没有任何问题,但除了自定义按钮

之外,其他按钮不显示
{
    text: 'Some button',
    key: '1',
    action: function (e, dt, node, config) {
        alert('Button activated');
    }
}

copy,pdf,excel不会出现,有人可以帮我解决问题吗?

2 个答案:

答案 0 :(得分:10)

我遇到了和你一样的问题,我发现需要包含所有 datatables-buttons js文件:

<script type="text/javascript" src="~/Scripts/datatables-buttons/js/dataTables.buttons.js"></script>
<script type="text/javascript" src="~/Scripts/datatables-buttons/js/buttons.bootstrap.js"></script>
<script type="text/javascript" src="~/Scripts/datatables-buttons/js/buttons.jqueryui.js"></script>
<script type="text/javascript" src="~/Scripts/datatables-buttons/js/buttons.colVis.js"></script>
<script type="text/javascript" src="~/Scripts/datatables-buttons/js/buttons.flash.js"></script>
<script type="text/javascript" src="~/Scripts/datatables-buttons/js/buttons.html5.js"></script>
<script type="text/javascript" src="~/Scripts/datatables-buttons/js/buttons.print.js"></script>

答案 1 :(得分:1)

表示excel和csv添加此cdn

npm run build

对于PDF文件选项添加此cdn

static