Skip to content
Icon

WARNING You're browsing the documentation for an old version of LARAVEL-DATATABLES. Consider upgrading your project to laravel-datatables 11.0.

Html Builder Macro

You can extend DataTables HTML Builder using macro.

Example macro:

use Yajra\Datatables\Html\Builder;
use Yajra\Datatables\Html\Column;
 
Builder::macro('addEditColumn', function () {
$attributes = [
'title' => 'Edit',
'data' => 'edit',
'name' => '',
'orderable' => false,
'searchable' => false,
];
 
$this->collection->push(new Column($attributes));
 
return $this;
});

Usage

$builder = new Builder;
$builder->addEditColumn()->ajax()->parameters([]);