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

rawColumns doesen't work with relation columns #2062

Closed
chojnicki opened this issue Apr 20, 2019 · 0 comments
Closed

rawColumns doesen't work with relation columns #2062

chojnicki opened this issue Apr 20, 2019 · 0 comments

Comments

@chojnicki
Copy link
Contributor

chojnicki commented Apr 20, 2019

Summary of problem or feature request

Hi. I cannot make datatables to work with columns in blade views. All works ok for regular columns, but not for relations. All these columns will print "[object Object]" in table ({} in json return). This happens only with blade files like "columns.user.login". In all files I have only "test" text (I can put exact same path in every column, and it will be error only in these with relation in it anyway).

If I remove rawColumns() or escapeColumns([]) then all works OK (but without rendering HTML of course).

What is weird - if I replace 'columns.user.login' with 'test' then again it works. Only not with separate blade files. Why?

I found similar problem here: #1151 It should be fixed, but no :(

I tried to test this with my old Laravel 5.5 instalation and datatables 8, and also same problem.

Is this bug? Any ideas? I

Code snippet of problem

$query = Video::select('id', 'title', 'user_id', 'created_at', 'updated_at')
   ->with('user:id,login');

return DataTables::eloquent($query)
   ->editColumn('title', 'columns.video.title') // works
   ->editColumn('user.login', 'columns.user.login') // nope
   ->addColumn('actions', 'columns.video.actions') // works
   //->escapeColumns([])
   ->rawColumns(['title', 'user.login', 'actions'])
   ->make();

System details

  • Ubuntu 18.04
  • PHP 7.2
  • Laravel 5.8 and 5.5
  • Laravel-Datatables 9.01 and 8.13.6
@chojnicki chojnicki changed the title Raw columns doesen't work with relation column rawColumns doesen't work with relation columns Apr 20, 2019
chojnicki added a commit to chojnicki/laravel-datatables that referenced this issue Apr 23, 2019
Fix Issue yajra#2062

Column with blade file is rendered by view() but it cannot be converted to json response. render() will return just HTML code.
Also without render if we try to debug $data inside DT source by Log or var_dump it will result with "Allowed memory size of xxx bytes exhausted".
@github-actions github-actions bot locked and limited conversation to collaborators Oct 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant