I am trying to add a checkbox to my DataTable but when I run my project it returns the checkbox in text as it is shown in my controller. How can I get this done from my controller?
When i run the project, i get the checkbox does not render in the template but shows raw text. What is happening ?
public function getItem()
{
$items = Item::all();
return Datatables::of($items)->addColumn('checkbox', function ($item) {
return '<input type="checkbox" id="'.item->id.'" name="someCheckbox" />';
})->make(true);
}
View
oTable = $('#users-table').DataTable({
"processing": true,
"serverSide": true,
"ajax": "{{ route('datatable.getitems') }}",
"columns": [
{data: 'checkbox', name: 'checkbox', orderable: false, searchable: false},
{data: 'name', name: 'name'},
{data: 'action', name: 'action', orderable: false, searchable: false}
],
});