Laravel-datatables: Passing data from controller to view.

Created on 28 May 2017  路  2Comments  路  Source: yajra/laravel-datatables

In short I'm trying to make inline editable datatable and I'm trying to pass array to view with editable columns.

Code snippet of problem

In my controller

$editable_cols = [
            'Id' => false,
            'Name' => true,
            'Email' => true,
            'Created at' => false,
            'Updated at' => false];

return $dataTable->render('datatables.dt_eloquent', compact($editable_cols));

And the result in my view is: "Undefined variable: editable_cols"

What is the proper way to pass that array to my view?

Also If anyone knows better way to do inline editable table - please share.

question

Most helpful comment

Instead of using compact do

$editable_cols = [
            'Id' => false,
            'Name' => true,
            'Email' => true,
            'Created at' => false,
            'Updated at' => false];

return $dataTable->render('datatables.dt_eloquent', ['editable_cols=>$editable_cols]);

All 2 comments

Instead of using compact do

$editable_cols = [
            'Id' => false,
            'Name' => true,
            'Email' => true,
            'Created at' => false,
            'Updated at' => false];

return $dataTable->render('datatables.dt_eloquent', ['editable_cols=>$editable_cols]);

It works, thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

ahmadbadpey picture ahmadbadpey  路  3Comments

sangnguyenplus picture sangnguyenplus  路  3Comments

shadoWalker89 picture shadoWalker89  路  3Comments

jgatringer picture jgatringer  路  3Comments