带有导出按钮的Laravel&HTML DataTable不显示或不显示

时间:2019-02-14 00:30:27

标签: javascript html laravel laravel-5 datatable

为什么我的导出按钮(如 PDF,EXCEL CSV )未显示或未显示在页面上?

这是我的桌子的样子

Imgur image of table

这是我的js链接

Imgur image of js links

    <table class="table" id="table_id">
        <thead>
          <tr>
            <th>EMPLOYEE NO.</th>
            <th>NAME</th>
            <th>DATE</th>
            <th>TIME IN</th>
            <th>TIME OUT</th>
            <th>TOTAL HOURS</th>
            <th>STATUS</th>

          </tr>
        </thead>
        <tbody>

                @foreach ($employeeSched as $setTime)
          <tr>
            <td><b>{{ $setTime->employee_no }}</b></td>
            <td><b>{{ $setTime->last_name }}, {{ $setTime->first_name }}</b></td>
             <td><b>{{Form::label('date_today', $setTime->date_today)}}</b></td>

             <td><input type="time" name="schedules[{{ $setTime->id }}][timeIn]" class="form-control col-md-11" value='{{ $setTime->time_in }}'></td>

            <td><input type="time" name="schedules[{{ $setTime->id }}][timeOut]" class="form-control col-md-11" value='{{ $setTime->time_out }}'></td>
            </td>
          </tr>
          @endforeach



        </tbody>
</table>

{{ $employeeSched->links() }}

和我的脚本

@section('script')


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

和我的 app.blade.php 中是我的链接

脚本

的链接
{!! Html::script('js/datatable/dataTables.buttons.min.js') !!}
{!! Html::script('js/datatable/buttons.flash.min.js') !!}
{!! Html::script('js/datatable/jszip.min.js') !!}
{!! Html::script('js/datatable/pdfmake.min.js') !!}
{!! Html::script('js/datatable/vfs_fonts.js') !!}
{!! Html::script('js/datatable/buttons.html5.min.js') !!}
{!! Html::script('js/datatable/buttons.print.min.js') !!}

css

的链接
{!! Html::style('css/buttons.dataTables.min.css') !!}
{!! Html::style('css/jquery.dataTables.min.css') !!}

1 个答案:

答案 0 :(得分:0)

我认为您的数据表不起作用。因为您没有相同数量的<th> and <td>。具有相同数量的th和td标签。还应按顺序使用波纹管脚本。

https://code.jquery.com/jquery-3.3.1.js
https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js
https://cdn.datatables.net/buttons/1.5.2/js/dataTables.buttons.min.js
https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js
https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js
https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js
https://cdn.datatables.net/buttons/1.5.2/js/buttons.html5.min.js

css

https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css
https://cdn.datatables.net/buttons/1.5.2/css/buttons.dataTables.min.css

和您的脚本:

@section('script')


<script type="text/javascript">
 $(document).ready(function() {
   $('#table_id').DataTable({
       dom: 'Bfrtip',
       buttons: [
           'copyHtml5','excelHtml5','csvHtml5','pdfHtml5','print'
       ]
   });
});
</script>
@endsection