Skip to content

Latest commit

 

History

History
39 lines (31 loc) · 948 Bytes

html-builder-column-builder.md

File metadata and controls

39 lines (31 loc) · 948 Bytes

Html Builder - Column Builder

Column Builder is a fluent class that we can use to build our columns.

Upgrading Your Existing Column Definitions

FROM

$column = [
	'name' => 'id',
	'data' => 'id',
	'title' => 'Id',
	'searchable' => true,
	'orderable' => true,
	'render' => 'function(){}',
	'footer' => 'Id',
	'exportable' => true,
	'printable' => true,
];

TO

use Yajra\DataTables\Html\Column;

$column = Column::make('id')
        ->title('Id')
        ->searchable(true)
        ->orderable(true)
        ->render('\'<div class="editor-active" >\' + (full[\'deleted_at\'] == null ? \'<i class="fas fa-check-circle client-is-active"></i>Active\' : \'<i class="fas fa-times-circle"></i>Inactive\') + \'</div>\';\'\'' )
        ->exportRender(function($row,$data){return $data == 1 ? 'Active' : 'Inactive'})
        ->footer('Id')
        ->exportable(true)
        ->printable(true);