Laravel-datatables: Datatable as a Service. Additional data to path.to.action.view

Created on 13 May 2016  路  2Comments  路  Source: yajra/laravel-datatables

Summary of problem or feature request

The problem that I've encounter is when I wanted to include additional data variable to be used in the view file rendered by the ->addColumn('action', 'path.to.action.view')

I understand that there are already data being passed to the view file. These data are the selected columns from the DB.

Looking at the builder.php file, is it unclear to me how additional data can be passed in.
public function addColumn(array $attributes) { $this->collection->push(new Column($attributes)); return $this; }

System details

  • OSX Yosemite 10.10.5
  • PHP 5.5.23
  • Laravel 5.2
  • DataTables 1.10.11

Most helpful comment

You can use closure if you want to pass more variables in the view like:

->addColumn('action', function($row) {
    $var = 'test';

    return view('path.to.action.view', compact('row', 'var')->render();
})

All 2 comments

You can use closure if you want to pass more variables in the view like:

->addColumn('action', function($row) {
    $var = 'test';

    return view('path.to.action.view', compact('row', 'var')->render();
})

Thank you for the fast response. I've got the problem solved thanks to you.
Cheers.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Mopster picture Mopster  路  3Comments

shadoWalker89 picture shadoWalker89  路  3Comments

josiahke picture josiahke  路  3Comments

FilipeBorges1993 picture FilipeBorges1993  路  3Comments

nasirkhan picture nasirkhan  路  3Comments