Laravel-datatables: Datentabellen als Service fügen Spalten zum Anzeigen, Bearbeiten und Löschen hinzu

Erstellt am 20. März 2016  ·  3Kommentare  ·  Quelle: yajra/laravel-datatables

Zusammenfassung des Problems oder der Funktionsanfrage

Ich plane, Datatables als Service zu verwenden und muss Spalten anzeigen, bearbeiten und löschen hinzufügen. Ich habe ein Beispiel in der Dokumentation gefunden (http://datatables.yajrabox.com/eloquent/add-edit-remove-column), konnte aber keines für 'Datatables as Service' finden.

Systemdetails

  • Laravel-Version: 5.1
  • Laravel-Datatables Version : "yajra/laravel-datatables-oracle": "~6.0"

Hilfreichster Kommentar

bekam die Lösungsformular ein anderes Problem.

public function ajax() {
        $query = $this->query();

        return $this->datatables
                        ->eloquent($this->query())
                        ->addColumn('action', function ($query) {
                            return '<a href="' . route("admin.districts.edit", $query->id) . '" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> Edit</a>';
                        })
                        ->make(true);
    }

Alle 3 Kommentare

bekam die Lösungsformular ein anderes Problem.

public function ajax() {
        $query = $this->query();

        return $this->datatables
                        ->eloquent($this->query())
                        ->addColumn('action', function ($query) {
                            return '<a href="' . route("admin.districts.edit", $query->id) . '" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> Edit</a>';
                        })
                        ->make(true);
    }

Hallo Yajra, ich muss die Schaltfläche zum Löschen und Bearbeiten mit einer anderen Spalte hinzufügen, aber ich verwende die Aktion, die nur eine Spalte verwendet. zeigen was ich tue?? kannst du mir helfen

bekam die Lösungsformular ein anderes Problem.

public function ajax() {
        $query = $this->query();

        return $this->datatables
                        ->eloquent($this->query())
                        ->addColumn('action', function ($query) {
                            return '<a href="' . route("admin.districts.edit", $query->id) . '" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> Edit</a>';
                        })
                        ->make(true);
    }

Für jeden, der dabei den rohen HTML-Code ausgedruckt bekommt, musste ich auch rawColumns('action') hinzufügen, um zu verhindern, dass der HTML-Code maskiert wird, dh:

public function ajax() {
        $query = $this->query();

        return $this->datatables
                        ->eloquent($this->query())
                        ->addColumn('action', function ($query) {
                            return '<a href="' . route("admin.districts.edit", $query->id) . '" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> Edit</a>';
                        })
                        ->rawColumns(['action'])
                        ->make(true);
    }
War diese Seite hilfreich?
0 / 5 - 0 Bewertungen

Verwandte Themen

vipin733 picture vipin733  ·  3Kommentare

ahmadbadpey picture ahmadbadpey  ·  3Kommentare

jackrsantana picture jackrsantana  ·  3Kommentare

ghost picture ghost  ·  3Kommentare

shadoWalker89 picture shadoWalker89  ·  3Kommentare