line break in laravel datatables column
DaveMolla opened this issue · comments
DaveMolla commented
Summary of problem or feature request
there are two datas that are fetched from the database, and they are being displayed side by side i want to display them above and below in that same column i have tried using
, \n and others but it is not working it just displays the tags
what i want is in the fixture_id column i want to display the localTeam and visitorTeam above and below
Code snippet of problem
public function dataTable($query)
{
$dataTable = new EloquentDataTable($query);
return $dataTable->addColumn('action', 'statistics.datatables_actions')
->editColumn('player_one_id', fn ($model) => $model->playerOne?->first_name['english'])
->editColumn('fixture_id', fn ($model) => $model->fixture->localTeam->team_name['english'].' Vs '.$model->fixture- >visitorTeam->team_name['english'])
->editColumn('player_two_id', fn ($model) => $model->playerTwo?->first_name['english'])
->editColumn('moment', fn ($model) => $model->action['english'])
->editColumn('action_time', fn ($model) => date('d-m-Y H:i:s', strtotime($model->action_time)));
}
System details
- Operating System:- ubuntu 23.04
- PHP Version:- 8.1
- Laravel Version:- 9.52
- Laravel-Datatables Version
Furkan Akkoc commented
You have to use <br>
as a line-break and add the column into ->rawColumns(['fixture_id'])
so it doesn't get escaped.
Arjay Angeles commented
You can also use the nl2br
function as needed.