2017-12-23 11 views
0

テーブルが多くの行を表示しています。また、ページ分割と並べ替え機能を使用しています。また、ajaxを使用して2つの日付間で行を返すように行やその他のajaxを返します。Laravel AJAXとURLなしのページ番号

問題は、行をソートして、同じ時間に2つの日付の間にいくつかの行を表示したい場合です。なぜなら、ajaxを使うときにはURLがないからです。

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()}}  
+0

通常のテーブルの代わりにdatatableを使用します。 inbuidはそこで機能します。内側の行のすべての比較を実行します –

+0

URLを渡す部分はどこですか? – Norgul

答えて

0

最良の方法はまた、uはまた、行をソートすることができているAjaxでデータテーブルを使用しhttps://datatables.net/ ..

+0

データシートが私のCSSデザインと矛盾します – Msaas

+0

最初のdatatablesを追加しようとしますcsssはあなた自身のcssを追加します – Jignesh

関連する問題