Laravel-datatables: Try to send html from controller

Created on 25 Apr 2017  路  1Comment  路  Source: yajra/laravel-datatables

Summary of problem or feature request

I want send to the table some HTML tags like

I use editColumn to add some HTML code to this column
its work with addColumn but not with editColumn
the question is how I can send HTML elements to table from controller the example above show the HTML tags when I need to view label

Code snippet of problem

public function CustomerTicketAjax(Request $request, $id)
{
    if ($request->ajax()) {
        $tickets = Customer::find($id);
        return Datatables::of(CustomerTicket::with('user')->where('customer_id', $tickets->id))

            ->editColumn('status', function ($tickets) {
                if ($tickets->status == 1) {
                    return '<span class="label bg-red" style="font-size: 21px;">open</span>';
                } elseif ($tickets->status == 0) {
                    return '<span class="label bg-red" style="font-size: 21px;">close</span>';
                };
            })

            ->make(true);
    }
}

System details

  • MAC OSX
  • PHP 7.1
  • Laravel 5.4
  • Laravel-Datatables 7.*
duplicate question

Most helpful comment

You need to specify which columns contains html using ->rawColumns(['status]).

>All comments

You need to specify which columns contains html using ->rawColumns(['status]).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hohuuhau picture hohuuhau  路  3Comments

alejandri picture alejandri  路  3Comments

ghost picture ghost  路  3Comments

Mopster picture Mopster  路  3Comments

FilipeBorges1993 picture FilipeBorges1993  路  3Comments