2017-06-05 15 views
0

Ich möchte Button in Yajra hinzufügen, so dass ich http://dt54.yajrabox.com/buttons/eloquent lesen. Ich folge dem Schritt. Aber immer noch leer anzeigen.Datatable Service Yajra Show leer

nb. wenn der Datatable-Dienst nicht ordnungsgemäß ausgeführt wird.

Datentabellen Klasse

Namespace App \ Tables;

use App\employee; 
use Yajra\Datatables\Services\DataTable; 
class EmployeeDataTable extends DataTable 
{ 

public function ajax() 
{ 
return $this->datatables 
->eloquent($this->query()) 
->make(true); 
} 

public function query() 
{ 
    $query = employee::select(); 

    return $this->applyScopes($query); 
} 

public function html() 
{ 
    return $this->builder() 
       ->columns($this->getColumns()) 
       ->ajax('{{ url("Employee/index3") }}') 
       ->parameters([ 
        'dom'   => 'Bfrtip', 
        'buttons'  => ['export', 'print', 'reset', 'reload'], 

       ]); 
} 

protected function filename() 
{ 
    return 'employeedatatables_' . time(); 
} 

in Controller-

use Yajra\Datatables\Facades\Datatables; 
use App\DataTables\EmployeeDataTable; 

public function index3(EmployeeDataTable $dataTable) 
{ 
    return $dataTable->render('employee.users'); 
} 

in View

@extends('layouts.app') 

@section('content') 
<div class="col-md-8 col-md-offset-2"> 
<h3>test</h3> 

{!! $dataTable->table() !!} 
</div> 
{!! $dataTable->scripts() !!} 
@endsection 

Wenn ich verwendet Firebug, ich habe Fehler 304 nicht geändert. Können Sie mir sagen, was mein Fehler, pls?

Antwort

0

Gelöst .. kann vielleicht helfen, jemand .. ist diese Spalte suchen, und fügen Sie Aktion mit Datatabale Service

in Datentabellen Klasse

public function ajax() 
{ 

    return $this->datatables 

     ->eloquent($this->query()) 
     ->addColumn('action', function ($query) { 
         return '<a href="#edit-'.$query->ID.'" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> Edit</a> 
        <a href="#delete-'.$query->ID.'" class="btn btn-xs btn-danger"><i class="glyphicon glyphicon-minus-sign"></i> Del</a>'; 
        }) 
     ->make(true); 
} 

public function query() 
{ 
    $query = employee::select('ID','cNip','vName','vBankbranch'); 

    return $this->applyScopes($query); 
} 

public function html() 
{ 
    return $this->builder() 
       ->columns($this->getColumns()) 
       ->addAction(['width' => '10%']) 
       ->ajax('') 
       ->parameters([ 
        'dom'   => 'Bfrtip', 
        'buttons'  => ['export', 'print', 'reset', 'reload'], 
        'initComplete' => "function() { 
         this.api().columns().every(function() { 
          var column = this; 
          var input = document.createElement(\"input\"); 
          $(input).appendTo($(column.footer()).empty()) 
          .on('change', function() { 
           column.search($(this).val(), false, false, true).draw(); 
          }); 
         }); 
        }", 
       ]); 
} 

in View

@extends('layouts.app') 
@section('content') 
<div class="col-md-8 col-md-offset-2"> 
<h3>test</h3> 
{!! $dataTable->table([], true) !!} 
</div> 
@endsection 
@section('scripts') 
{!! $dataTable->scripts() !!} 
@endsection 
Verwandte Themen