Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel datatable addColumn not working

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}
        ]
  
    });
Source by datatables.yajrabox.com #
 
PREVIOUS NEXT
Tagged: #laravel #datatable #addColumn #working
ADD COMMENT
Topic
Name
2+1 =