I am beginner in Laravel. I use in my project Laravel 7. I use yajra/laravel-datatables in my project.
I have this code:
<table class="table table-bordered data-table ">
<thead>
<tr>
<th>ID</th>
<th>Tytuł</th>
<th>Status</th>
<th width="100px">Akcja</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
$(function () {
var table = $('.data-table').DataTable({
processing: true,
serverSide: true,
ajax: "",
columns: [
{data: 'DT_RowIndex', name: 'DT_RowIndex'},
// {data: 'id', name: 'id'},
{data: 'title', name: 'title'},
{data: 'enable', name: 'enable'},
{data: 'action', name: 'action', orderable: false, searchable: false},
]
});
});
and controller:
public function tabelka2(Request $request)
{
// return Datatables::of(Page::query())->make(true);
if ($request->ajax()) {
$data = Page::get();
return Datatables::of($data)
->addIndexColumn()
->addColumn('action', function($row){
//$btn .= '<a href="javascript:void(0)" class="edit btn btn-primary btn-sm">View</a>';
$btn = '<a href="javascript:void(0)" class="edit btn btn-primary btn-sm"></a> ';
$btn .= '<a href="javascript:void(0)" class="edit btn btn-primary btn-sm"></a> ';
return $btn;
})
->rawColumns(['action'])
->make(true);
}
}
It's work fine.
- How do I search for columns other than title, enable? I need to search for description and keywords.
- If enable = 1 - I would like to display "active". Otherwise "inactive"
- I would like to "pack" the title value in: ...])}} "> description
Anyone know how to do this? Please help
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2TGj0pX
via IFTTT
Aucun commentaire:
Enregistrer un commentaire