数据表-同一页上有多个表,但只有一个附加按钮

问题描述

我正在使用semantic-ui并有2个表,只有最上面的表附加了按钮:

    <link rel="stylesheet" type="text/css" href="{% static 'default/Semantic-UI-CSS-master/semantic.css' %}"/>
    <link rel="stylesheet" type="text/css" href="{% static 'default/dataTables.semanticui.min.css' %}"/>
    <link rel="stylesheet" type="text/css" href="{% static 'default/buttons.semanticui.min.css' %}"/>
    <script src="{% static 'default/jquery-3.3.1.js' %}"></script>
    <script src="{% static 'default/jquery.dataTables.min.js' %}"></script>
    <script src="{% static 'default/dataTables.semanticui.min.js' %}"></script>
    <script src="{% static 'default/semantic.min.js' %}"></script>
    <script src="{% static 'default/Semantic-UI-CSS-master/semantic.js' %}"></script>
    <script type="text/javascript" src="{% static 'DataTables/JSZip-2.5.0/jszip.min.js' %}"></script>
    <script type="text/javascript" src="{% static 'DataTables/pdfmake-0.1.36/pdfmake.min.js' %}"></script>
    <script type="text/javascript" src="{% static 'DataTables/pdfmake-0.1.36/vfs_fonts.js' %}"></script>
    <script type="text/javascript" src="{% static 'DataTables/Buttons-1.6.3/js/dataTables.buttons.min.js' %}"></script>
    <script type="text/javascript" src="{% static 'DataTables/Buttons-1.6.3/js/buttons.semanticui.min.js' %}"></script>
    <script type="text/javascript" src="{% static 'DataTables/Buttons-1.6.3/js/buttons.colVis.min.js' %}"></script>
    <script type="text/javascript" src="{% static 'DataTables/Buttons-1.6.3/js/buttons.flash.min.js' %}"></script>
    <script type="text/javascript" src="{% static 'DataTables/Buttons-1.6.3/js/buttons.html5.min.js' %}"></script>
    <script type="text/javascript" src="{% static 'DataTables/Buttons-1.6.3/js/buttons.print.min.js' %}"></script>

表格:

<table class="ui selectable very compact celled striped table">
  -- table #1--
</table>
<table class="ui selectable very compact celled striped table">
  -- table #2--
</table>

我的JavaScript:

    $(document).ready(function() {
        var table = $('table.ui').DataTable( {
        "paging": false,"lengthChange": true,"buttons": [ 'copy','excel','print','colvis' ]
        } );
        table.buttons().container()
            .appendTo( $('div.eight.column:eq(0)',table.table().container()) );
    } );

我尝试使用以下建议未成功:

datatable - multiple tables on same page,but only one is responding

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)