Reputation: 266
I am trying to get some HTML with my dataTable request.
I use Laravel DataTable library. When I get the data, the page displays the HTML as a normal text in the column which I don't want, I wanna display it as a normal HTML.
public function suppliers(){
$Suppliers = Suppliers::getSuppliersView();
return Datatables::of($Suppliers)
->addColumn('operations', '<button id="{{ $serial_no }}" class="btn btn-primary">Edit</button>')
->rawColumns(['operations'])
->make();
}
Any help about this issue? Thanks.
Upvotes: 3
Views: 3541
Reputation: 2480
$users = $user->all();
return Datatables::of($users)
->addColumn('feature', function($row) {
return $row->feature ;
})->escapeColumns([])
->make(true);
Upvotes: 3
Reputation: 266
I found the solution since a while,
We can use
->escapeColumns(['operations'])
and set the name of each column we want to display its HTML.
It may help someone else too. Thank you...
Upvotes: 4
Reputation: 447
Displaying Unescaped Data
By default, Blade {{ }} statements are automatically sent through PHP's htmlspecialchars function to prevent XSS attacks. If you do not want your data to be escaped, you may use the following syntax:
Hello, {!! $name !!}.
Try changing your blade tags to
{!! $serial_no !!}
Upvotes: 0