【发布时间】:2021-03-09 04:20:08
【问题描述】:
在打印使用 jQuery 数据表的网页时,我试图删除最后一个操作行。我正在使用数据表来显示数据并且可以正常工作,但是当我尝试打印默认打印选项时,它会打印编辑/删除部分。
这是我的桌子:
<table id="dataTable" class="table table-bordered text-center">
<thead>
<tr>
<th width="5%">SN</th>
<th>Customer Code</th>
<th>Customer Name</th>
<th>customer address</th>
<th>customer phone</th>
<th>customer city</th>
<th>customer email</th>
<th>openig due</th>
<th>customer status</th>
<th width="8%" class="text-center">Action</th>
</tr>
</thead>
<tbody>
@php $i=1; @endphp
@foreach($customer as $row)
<tr>
<td>{{$i++}}</td>
<td>{{$row->customer_code}}</td>
<td>{{$row->customer_name}}</td>
<td>{{$row->customer_address}}</td>
<td>{{$row->customer_phone}}</td>
<td>{{$row->customer_city}}</td>
<td>{{$row->customer_email}}</td>
<td>{{$row->openig_due}}</td>
<td>
@if($row->customer_status==1)
<a href="#" class="btn btn-sm btn-success">active</a>
@else
<a href="#" class="btn btn-sm btn-danger">deactive</a>
@endif
</td>
<td >
<a href="{{url('admin/customerEdit/'.$row->id)}}" class="btn btn-warning btn-sm waves-effect waves-light">
<i class="fa fa-edit"></i> <span>
Edit
</span>
</a>
<a href="{{url('admin/customerdlt/'.$row->id)}}" class="btn btn-danger btn-sm waves-effect waves-light" id="delete"> X
<i class="fa fa-delete"></i> <span>
Delete
</span>
</a>
</td>
</tr>
@endforeach
</tbody>
</table>
这是我的数据表 jquery
$("#dataTable").DataTable({
processing: true,
serverSide: true,
aaSorting: [],
columnDefs: [ { orderable: false, targets: [0,-1] }],
ajax: dataUrl,
buttons: {
buttons: [
{ extend: 'excel', className: 'btn-outline-dark' },
{ extend: 'print', className: 'btn-outline-dark'}
]
}
}).buttons().container().appendTo('#dataTable_wrapper .col-md-6:eq(0)');
如何在单击打印按钮时删除最后一行?
【问题讨论】:
-
这个页面的最后一个解决方案有一个Javascript函数来创建一个打印按钮来隐藏最后一列。 stackoverflow.com/questions/13649569/…
标签: jquery ajax laravel datatable