Linked Questions

Popular Questions

I search set Column Class for laravel-datatables

Asked by At

In my laravel 5.7/ blade / jQuery v3.3.1 / Bootstrap v4.1.2 app

I use "yajra/laravel-datatables-oracle": "~8.0" library and when I need to change class of some rows depending on value of some field I do :

return Datatables
    ::of($votesCollection)
    ->setRowClass(function ($vote) {
        return $vote->status == 'N' ? ' row_new_status' : ($vote->status == 'I' ? 'row_inactive_status' : '');
    })

It works ok, but I did not find any similar methods for columns. Are there ? Can it be implemented in some way ?

UPDATED # 1: In my blade file I define header of the table :

<div class="table-responsive">
    <table class="table table-bordered table-striped text-primary" id="get-warehouse-dt-listing-table">
        <thead>
        <tr>
            <th>Id</th>
            <th>Name</th>
            <th>Location</th>
            <th>Level count</th>
            <th>Created At</th>
            <th>Updated At</th>
            <th></th>
            <th></th>
        </tr>
        </thead>
    </table>

</div>

but not generated rows. Or can I define it in blade? Please example, if yes.

Thanks!

Related Questions