0

Environment: Laravel 5.4, Acacha\Adminlte, Yajra/laravel-datatables

HTML Code in Datatable in Laravel 5.4, not parsing code in webpage, in Laravel 5.3.* is working ok.

Code snippet of problem

public function data()
{
    DB::statement(DB::raw('set @rownum=0'));
    $result = My_Model::select(array(
        DB::raw('@rownum  := @rownum  + 1 AS rownum'),
        'created_at',
        'name'));

    $datatables = Datatables::of($result)
        ->edit_Column('rownum', '<div style="text-align:center;"><a class="btn btn-primary btn-xs">{{ $rownum }}</a></div>')
        ->edit_Column('created_at','<div style="text-align:center;">{{ App\Functions::setDateTime($created_at) }}')
        ->edit_Column('name', '<div style="text-align:left;"><a class="btn btn-success btn-xs">{{ $name}}</a></div>');

    return $datatables->make(true);
}

Result displayed in datatable in webpage, just this text, not a button with value 1:

<div style="text-align:center;"><a class="btn btn-primary btn-xs">1</a></div>

System details

Operating System: Windows 7 Professional
PHP Version: 7.0.10 (from Laragon 2.2.2)
Laravel Version: 5.4.11
Laravel-Datatables Version: 7.1.4 & 7.2.1

1 Answer 1

2

Solved.

Solution here: Escape columns by default

Adding rawColumns:

$datatables = Datatables::of($result)->rawColumns(['rownum','created_at','name']) ...
Sign up to request clarification or add additional context in comments.

Comments

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.