Laravel DataTable AddColumn no funciona
1. have the same number of <th> in html.
<th>ID</th>
<th>Name</th>
<th>Action</th>
2. in laravel controller
return Datatables::of($users)
->addColumn('action', function ($user) {
return '<a href="#edit-'.$user->id.'" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> Edit</a>';
})
->make(true);}
3. javascript
$('#users-table').DataTable({
processing: true,
serverSide: true,
ajax: 'https://datatables.yajrabox.com/eloquent/add-edit-remove-column-data',
columns: [
{data: 'id', name: 'id'},
{data: 'name', name: 'name'},
{data: 'action', name: 'action', orderable: false, searchable: false}
]
});
ilham uum