Laravel-datatables: datatables laravel returned html element as a text

Created on 31 Jul 2017  ·  33Comments  ·  Source: yajra/laravel-datatables

The laravel datatables return an HTML as a text I used a rawColumns and escapeColumns but not working

Please what a solution and thank you

Please find a below pictures
dara
dara2

Code snippet of problem

System details

  • Operating System
  • PHP Version
  • Laravel Version 5.3
  • Laravel-Datatables Version 7.9
bug

Most helpful comment

try ->escapeColumns('') instead, but an empty array should work aswell i don't undestand.

All 33 comments

Hello,

it's normal, escapeColumn is for escaping columns, so it's escaped.

But, what I should do, to return HTML element?
Thank you for your response

you can use rawColumns(['link'])

I used it, this same problem appeared

try to use version 7.9.5, it's working for me, perhaps it's a recent bug.

edit :
i think i found the bug, there is a array_diif_key inside escapeColumns in DataProcessor
try ['link' => true] or something like that.

I used the last version of datatables laravel,
I tried also ['link' => true] but not working ,
Must i upgrade laravel version to 5.4 ?

i don't think it will solve your issue

What should I do in your opinion?

you tried escapeColumns(['link' => true) or rawColumns(['link' => true]) ?

Yes, it is.

i mean which one you tested ?
you could try escapeColumns([]) as well.

I tested them both

escapeColumns([]) should disable escaping on all columns as a workaround

I tried all solutions but nothing be changed

and escapeColumns(null) ?

Same problem,
I have question, why the action column return HTML but the link not?

it should work i don't understand.
you removed all the escapeColumns calls ?

How can i remove all escapeColumns calls? and why?

inside your code i mean,
because if your doing rawColumns
and next do the opposite with escapeColumns somewhere else in your code.

My code now is
return Datatables::of($row)
->addColumn('link', 'Html Column
')
->addColumn('action', 'Html Column
')
->escapeColumns(null)
->make(true);

try ->escapeColumns('') instead, but an empty array should work aswell i don't undestand.

Same problem, I also don't understand why the action work probably but the link no

the action work because it's not escaped by default

Thank you for your effort,

There is any way to find a solution ?

Have released a patch v7.9.8. Can you please verify if it fixes the issue? Thanks and sorry for the inconvenience.

How I can upgrade to the last release?

i think you should try :

[
    'link' => 'link'
];

the latest release does not fix this issue, for me.

if i do :

->escapeColumns(['action' => 'action'])
->rawColumns(['action'])

the action column is escaped, and if i do :

->escapeColumns(['action' => 'action'])
->rawColumns(['action => 'action'])

the column is not escaped anymore.

How i can update my version to 7.9.8

you can change your composer.json and set yajra/laravel-datatables to 7.9.8
and then do composer update yajra/laravel-datatables

or you can do composer require yajra/laravel-datatables 7.9.8 directly, it will change your composer.json and update the package

Ok, I'll try it
Thank you

Finally, it works,
Thank you Yajre and IK77
i used escapeColumn['link'] in last version it working probably

for versions above 8, u have to go to config/datatables.php file....and add your column name in ....raw => ['name_of your_column']

Was this page helpful?
0 / 5 - 0 ratings

Related issues

t0n1zz picture t0n1zz  ·  3Comments

techguydev picture techguydev  ·  3Comments

sangnguyenplus picture sangnguyenplus  ·  3Comments

Abdulhmid picture Abdulhmid  ·  3Comments

FilipeBorges1993 picture FilipeBorges1993  ·  3Comments