2017-11-21 32 views
0

테이블 (데이터 테이블 사용)을 만들고 테이블에서 몇 가지 작업을 수행했습니다. 테이블에 나는 "delete"함수를 수행하는 버튼이 있습니다. 또한 datatables를 사용하여 페이지 매김을 얻습니다. 그래서 예를 들어 5 페이지에있는 예를 들어 삭제를 클릭하면 페이지를 새로 고침하고 되돌아갑니다 1 번 페이지로 이동합니다. 어떻게 액션을 삭제 한 후 페이지 5에 남겨 둘 수 있습니까? 다음은 내 테이블과 컨트롤러 기능작업 후 테이블에서 동일한 페이지 매김 페이지 유지 방법

viewStatistics.blade 있습니다

<table class="table table-hover demo-table-search table-responsive-block alt-table" id="tableWithSearch"> 
 
    <thead> 
 
    <tr> 
 
     <th class="text-center" style="width:80px;">ID</th> 
 
     <th class="text-center">Date</th> 
 
     <th class="text-center">Question <br> Asked</th> 
 
     <th class="text-center">Low <br> Confidence</th> 
 
     <th class="text-center">No <br> Answer</th> 
 
     <th class="text-center">Missing <br> Intent</th> 
 
     <th class="text-center">Webhook <br> Fail</th> 
 
     <th class="text-center">Status</th> 
 
     <th class="text-center">Action</th> 
 
    </tr> 
 
    </thead> 
 
    <tbody> 
 
    @foreach($data as $sessionID => $value) 
 
     <tr> 
 
     <td class="text-center">{{$value['identifier']}}</td> 
 
     <td class="text-center">{{date("d M", strtotime($value['dateAccess']))}}</td> 
 
     <td class="text-center">{{$value['total']}}</td> <!-- question asked --> 
 
     <td class="text-center">{{$value['low confidence']}}</td> <!-- low confidence --> 
 
     <td class="text-center">{{$value['no answer']}}</td> <!-- no answer --> 
 
     <td class="text-center">{{$value['missing intent']}}</td> <!-- missing intent --> 
 
     <td class="text-center">{{$value['webhook fail']}}</td> <!-- webhook fail --> 
 
     <td class="text-center" style="{{$value['status'] == 'Reviewed' ? 'color:green' : 'color:red'}}"> 
 
      {{$value['status']}} 
 
      @if($value['status'] == 'Pending') 
 
      <input type="checkbox" name="check" class="check" value="{{$sessionID}}"> 
 
      @endif 
 
     </td> <!-- status --> 
 
     <td class="text-center"> 
 
      <div class="btn-group"> 
 
      <button type="button" class="btn alt-btn alt-btn-black dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Manage</button> 
 
      <ul class="dropdown-menu"> 
 
       <li> 
 
       <a href="{{action('AltHr\Chatbot\[email protected]', [$companyID, $sessionID, $value['status'], $value['identifier']])}}" class="btn btn-link">View</a> 
 
       </li> 
 
       <li> 
 
       <a href="{{action('AltHr\Chatbot\[email protected]', [$companyID, $sessionID])}}" class="btn btn-link" onclick="return confirm('Are you sure that you want to delete this chat logs?')">Delete</a> 
 
       </li> 
 
       @if($value['status'] == 'Pending') 
 
       <li> 
 
       <a href="{{action('AltHr\Chatbot\[email protected]', [$companyID, $sessionID])}}" class="btn btn-link">Mark as Done</a> 
 
       </li> 
 
       @endif 
 
      </ul> 
 
      </div> 
 
     </td> <!-- action --> 
 
     </tr> 
 
    @endforeach 
 
    </tbody> 
 
</table>

컨트롤러 :

public function deleteStatistics($companyID, $sessionID) 
 
{ 
 
    DiraChatLog::where('company_id', $companyID)->where('sessionID', $sessionID)->delete(); 
 
    return redirect(action('AltHr\Chatbot\[email protected]', compact('companyID')))->with('notification',[ 
 
    'status' => 'success', 
 
    'title' => 'Statistics Deleted', 
 
    'message' => 'The Statistics have been deleted.' 
 
    ]); 
 
}

답변

2

목 ere는 jquery 데이터 테이블에 stateSave이라는 옵션입니다. 아래 코드를 확인하십시오 :

$('#example').dataTable({ stateSave: true }); 
+0

안녕하세요, 저는 laravel에서 이것을 수행하기 때문에 블레이드 파일에이 코드를 사용해야합니까? – anon

+0

예, 추가 할 수 있습니다. –

+0

감사합니다. 또한 datatables 내가 건너 뛸 수있는 코드를 추가 할 수 있는지 알고 계십니까> 건너 뛰기 5, 또는> 건너 뛰기 10? – anon