3

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.

0

3 Answers 3

4

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...

Sign up to request clarification or add additional context in comments.

Comments

3
  $users = $user->all();
    return Datatables::of($users)
        ->addColumn('feature', function($row) {
            return  $row->feature ;
        })->escapeColumns([])
        ->make(true);

Comments

0

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 !!}

2 Comments

I just found the solution, and posted the answer. Check it if interested.
It is not about blade, Rows are going to be displayed through AJAX request, using JQuery DataTables, this can not help in this situation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.