Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/369.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript yii2框架中没有出现DataTable按钮_Javascript_Php_Button_Datatables_Yii2 Advanced App - Fatal编程技术网

Javascript yii2框架中没有出现DataTable按钮

Javascript yii2框架中没有出现DataTable按钮,javascript,php,button,datatables,yii2-advanced-app,Javascript,Php,Button,Datatables,Yii2 Advanced App,嗨,我在Yii 2框架中使用数据表。我跟踪并添加了页面中的所有内容,所有js和css。 首先,我将所有内容保存在一个普通的PHP页面中并运行,该页面中的所有内容都正常工作,所有按钮都没有出现,下载excel也正常工作 但是如果我在YiI2框架中集成了同一个页面,并在这个框架中运行它,除了文件下载之外,其他一切都正常,按钮都出现了,我重新检查了所有的js和css,那么它也不正常 这是脚本代码 <link href="https://cdn.datatables.net/1.10.13/css

嗨,我在Yii 2框架中使用数据表。我跟踪并添加了页面中的所有内容,所有js和css。
首先,我将所有内容保存在一个普通的PHP页面中并运行,该页面中的所有内容都正常工作,所有按钮都没有出现,下载excel也正常工作

但是如果我在YiI2框架中集成了同一个页面,并在这个框架中运行它,除了文件下载之外,其他一切都正常,按钮都出现了,我重新检查了所有的js和css,那么它也不正常

这是脚本代码

<link href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css" rel="stylesheet">
<link href="https://cdn.datatables.net/buttons/1.2.3/css/buttons.dataTables.min.css" rel="stylesheet">

<script src="//code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.2.3/js/dataTables.buttons.min.js"></script>
<script src="//cdn.datatables.net/buttons/1.2.3/js/buttons.flash.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js"></script>
<script src="//cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/pdfmake.min.js"></script>
<script src="//cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/vfs_fonts.js"></script>
<script src="//cdn.datatables.net/buttons/1.2.3/js/buttons.html5.min.js"></script>
<script src="//cdn.datatables.net/buttons/1.2.3/js/buttons.print.min.js"></script>

<script>
    $(document).ready(function() {
$('#example').DataTable( {
    dom: 'Bfrtip',
    buttons: [
        'copy', 'csv', 'excel', 'pdf', 'print'
    ]
} );
 } );
</script>


 <table id="example" class="display nowrap" width="100%" cellspacing="0">
    <thead>
        <tr>
            <th>Name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
        </tr>
    </thead>

    <tbody>
        <tr>
            <td>Tiger Nixon</td>
            <td>System Architect</td>
            <td>Edinburgh</td>
            <td>61</td>
            <td>2011/04/25</td>
            <td>$320,800</td>
        </tr>
        <tr>
            <td>Garrett Winters</td>
            <td>Accountant</td>
            <td>Tokyo</td>
            <td>63</td>
            <td>2011/07/25</td>
            <td>$170,750</td>
        </tr>
  </tbody>
</table>

$(文档).ready(函数(){
$('#示例')。数据表({
dom:'Bfrtip',
按钮:[
“复制”、“csv”、“excel”、“pdf”、“打印”
]
} );
} );
名称
位置
办公室
年龄
开始日期
薪水
老虎尼克松
系统架构师
爱丁堡
61
2011/04/25
$320,800
加勒特温特斯
会计
东京
63
2011/07/25
$170,750
我终于解决了这个问题。 问题是js相互冲突,我必须将上面的js、css和javascript代码提供给常见的文件,比如footer

将下面的js、css和javascript代码复制到页脚页面

<link href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css" rel="stylesheet">
<link href="https://cdn.datatables.net/buttons/1.2.3/css/buttons.dataTables.min.css" rel="stylesheet">

<script src="//code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
 <script src="https://cdn.datatables.net/buttons/1.2.3/js/dataTables.buttons.min.js"></script>
<script src="//cdn.datatables.net/buttons/1.2.3/js/buttons.flash.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js"></script>
<script src="//cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/pdfmake.min.js"></script>
<script src="//cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/vfs_fonts.js"></script>


$(文档).ready(函数(){
$('#示例')。数据表({
dom:'Bfrtip',
按钮:[
“复制”、“csv”、“excel”、“pdf”、“打印”
]
} );
} );

这不是在使用flash吗?而是在使用flash.min.js。。按钮本身不会下载我不知道这是问题所在,但我相信现在Chrome默认禁用了flash。这可能是一个很好的理由?有一个html5等价物,我如何启用它?我在同样的问题上尝试了那个链接。我相信我刚刚发布的链接中提到了所有内容。
 <script>
$(document).ready(function() {
 $('#example').DataTable( {
dom: 'Bfrtip',
buttons: [
    'copy', 'csv', 'excel', 'pdf', 'print'
]
} );
} );
</script>