我有表显示多行,我使用分页和排序功能,我也使用ajax返回行数,其他ajax返回两个日期之间的行。
问题是如果我想对行进行排序,同时在两个日期之间显示一些行,这对我不起作用。因为使用ajax时没有网址。
public function index()
{
$checks = Checks::orderBy('id', 'asc')->get();
$checks= Checks::sortable()->paginate(10);
return view('home',compact('checks'));
}
public function showpage(Request $request)
{
if($request->ajax())
{
$checks= Checks::orderBy('id', 'asc')->paginate($request->inputpage);
return view('layouts.showcheks',compact('checks'));
}
}
public function getCheckReport(Request $request)
{
if($request->ajax()){
$New=$request->StartDate;
$Old=$request->EndDate;
$checks= Checks::whereBetween('postingdate',[$New,$Old])->sortable()->orderBy('postingdate', 'asc')->get();
return view('layouts.showcheks',compact('checks'));
}
}
showchecks.blade.php
@foreach($checks as $indexKey => $check)
<tr >
<td>{{$check->details}}</td>
<td>{{date('m/d/Y', strtotime($check->postingdate))}}</td>
<td>{{$check->description}}</td>
</tr>
@endforeach
主页:
<table class="table" id="postTable">
<thead>
<tr>
<th>@sortablelink('details','Details')</th>
<th>@sortablelink('postingdate','Date')</th>
<th>@sortablelink('description','Description')</th>
</tr>
{{ csrf_field() }}
</thead>
<tbody>
@foreach($checks as $indexKey => $check)
<tr >
<td>{{$check->details}}</td>
<td>{{date('m/d/Y', strtotime($check->postingdate))}}</td>
<td >{{$check->description}}</td>
</tr>
@endforeach
</tbody>
</table>
{{$checks->appends(Request::input())->links()}}