이 패키지 https://github.com/yajra/laravel-datatables을 패키지에 추가했으며이를 응용 프로그램에서 사용하려고합니다. Laravel 5.4 with datatables
이
는이 컨트롤러public function getTasks()
{
return Datatables::of(Employees::query())->make(true);
//returns json
}
이 코드는 datatables를 containining보기를로드 인 경로
Route::get('tasks', '[email protected]')->name('datatable.tasks');
이다보기
@section('content')
<table class="table table-bordered" id="users-table">
<thead>
<tr>
<th>Emp No</th>
<th>Birth Date</th>
<th>First Name</th>
<th>Last Name</th>
<th>Gender</th>
<th>Hire Date</th>
</tr>
</thead>
</table>
@stop
@push('scripts')
<script type="text/javascript">
$(function() {
$('#users-table').DataTable({
processing: true,
serverSide: true,
responsive: true,
ajax: 'http://localhost:8000/tasks',
columns: [
{ data: 'emp_no', name: 'emp_no' }
{ data: 'birth_date', name: 'birth_date' },
{ data: 'first_name', name: 'first_name' },
{ data: 'last_name', name: 'last_name' },
{ data: 'gender', name: 'gender' },
{ data: 'hire_date', name: 'hire_date' }
]
});
});
</script>
@endpush
@endsection
입니다.
URL http://localhost:8000/tasks은 웹 브라우저에서 json을 반환하지만 데이터 테이블은 절대로 내보기에서 렌더링되지 않습니다. 내보기에 체크인 할 때 브라우저 오류가 없습니다.
무엇이 문제일까요?.
부트 스트랩을 그 'Route :: get ('tasks ','PrototypeController @ getTasks ') -> name (') '이라는 뷰를 표시하고, 다른 하나는 ajax 요청을 처리하기 위해 Route :: get ('bulkOutbox ','PrototypeController @ bulkOutbox ' 'dat ' –
이 뷰를 렌더링하고 해당 URL을 실행하는 첫 번째 bulkOutbox http : // localhost : 8000/bulkOutbox –
먼저 bulkOutbox를로드 중이며 아무것도 표시하지 않습니다. mysql 샘플 데이터베이스를 설치했다면, 그것을 테스트 할 수 있습니다. –