Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

datatables laravel returned html element as a text #1305

Closed
AbuHamdah opened this issue Jul 31, 2017 · 33 comments
Closed

datatables laravel returned html element as a text #1305

AbuHamdah opened this issue Jul 31, 2017 · 33 comments
Labels

Comments

@AbuHamdah
Copy link

AbuHamdah commented Jul 31, 2017

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
@lk77
Copy link
Contributor

lk77 commented Jul 31, 2017

Hello,

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

@AbuHamdah
Copy link
Author

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

@lk77
Copy link
Contributor

lk77 commented Jul 31, 2017

you can use rawColumns(['link'])

@AbuHamdah
Copy link
Author

I used it, this same problem appeared

@lk77
Copy link
Contributor

lk77 commented Jul 31, 2017

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.

@AbuHamdah
Copy link
Author

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

@lk77
Copy link
Contributor

lk77 commented Jul 31, 2017

i don't think it will solve your issue

@AbuHamdah
Copy link
Author

What should I do in your opinion?

@lk77
Copy link
Contributor

lk77 commented Jul 31, 2017

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

@AbuHamdah
Copy link
Author

Yes, it is.

@lk77
Copy link
Contributor

lk77 commented Jul 31, 2017

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

@AbuHamdah
Copy link
Author

I tested them both

@lk77
Copy link
Contributor

lk77 commented Jul 31, 2017

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

@AbuHamdah
Copy link
Author

I tried all solutions but nothing be changed

@lk77
Copy link
Contributor

lk77 commented Jul 31, 2017

and escapeColumns(null) ?

@AbuHamdah
Copy link
Author

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

@lk77
Copy link
Contributor

lk77 commented Jul 31, 2017

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

@AbuHamdah
Copy link
Author

How can i remove all escapeColumns calls? and why?

@lk77
Copy link
Contributor

lk77 commented Jul 31, 2017

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

@AbuHamdah
Copy link
Author

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

@lk77
Copy link
Contributor

lk77 commented Jul 31, 2017

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

@AbuHamdah
Copy link
Author

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

@lk77
Copy link
Contributor

lk77 commented Jul 31, 2017

the action work because it's not escaped by default

@AbuHamdah
Copy link
Author

Thank you for your effort,

@AbuHamdah
Copy link
Author

There is any way to find a solution ?

@yajra
Copy link
Owner

yajra commented Aug 1, 2017

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

@yajra yajra added the bug label Aug 1, 2017
@AbuHamdah
Copy link
Author

How I can upgrade to the last release?

@lk77
Copy link
Contributor

lk77 commented Aug 1, 2017

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.

@AbuHamdah
Copy link
Author

How i can update my version to 7.9.8

@lk77
Copy link
Contributor

lk77 commented Aug 1, 2017

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

@AbuHamdah
Copy link
Author

Ok, I'll try it
Thank you

@AbuHamdah
Copy link
Author

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

@robiparvez
Copy link

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

@github-actions github-actions bot locked and limited conversation to collaborators Oct 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants