Hi @yajra,
I trying to use rawColumns but doesn't work (all columns render HTML)
When I use ->escapeColumns([]) works well, but for all the columns and I want this only for three columns. I tried with ->escapeColumns(['active', 'edit', 'name']) but doesn't work either.
Thank you for your work :))
return Datatables::of($objects)
->addColumn('edit', function($object) {
return '<a href="myroute"><button class="btn btn-sm">edit </button></a>';
})
->editColumn('active', function($object) {
if ($object->active) {
return '<span class="label label-sm label-success">active</span>';
}
return '<span class="label label-sm label-danger">inactive</span>';
})
->rawColumns(['active', 'edit', 'name'])
->make();
The columns active,edit and name show the html as text, instead of render this.
I want to choose what columns will be rendered as HTML.
It seems like rawColumns is being ignored when using make(false). Will try to fix this as soon as I can. Thanks for reporting.
Not a bug, since you are using make(false), you need to use the index of the column instead of name like:
->rawColumns([3,4,5])
Added on Laravel 5.4 demo for initial documentation. Thanks
Thanks @yajra :))
BTW, You know a lot about laravel... (Do not deny it!!) Do you use some package like mewebstudio/Purifier for sanitize all your inputs before save it on the database?
Regards and thanks!!
@joanebrown I just learned a lot from Laracasts. :)
Yes, I have used that package (mewebstudio/Purifier) to sanitize my input on some of my projects.
Thank you :)
Hi, there.
I'm having an issue with rawColumns. This is my scenario:
`$invoices = User::byRole('participant')->select('users.*')->findOrfail($id)->invoices()->with('city','department','store');
return Datatables::eloquent($invoices)
->editColumn('created_at', function(Invoice $invoice) {
return Date::parse($invoice->created_at)->toFormattedDateString();
})
->editColumn('buyed_at', function(Invoice $invoice) {
return Date::parse($invoice->buyed_at)->toFormattedDateString();
})
->editColumn('total', function(Invoice $invoice) {
return $invoice->totalFormatted;
})
->editColumn('store.name', function(Invoice $invoice) {
return $invoice->store->name.'<br><strong>'.$invoice->city->name.', '.$invoice->department->name.'</strong>';
})
->rawColumns(['store.name','total'])
->make(true);`
as you can see, the field store.name which is a relationship loaded via Eager Loading works well, but on the front-end is the html is not interpreted even if I configured the field in the rawColumns. As you can see in the printscreen.

What am I doing wrong? Sorry if my english is not perfect.