yajra / laravel-datatables

jQuery DataTables API for Laravel
https://yajrabox.com/docs/laravel-datatables
MIT License
4.76k stars 857 forks source link

Laravel Yajra with barcode #3192

Open markplus opened 3 days ago

markplus commented 3 days ago

Summary of problem or feature request

I would like to add a barcode with the data of the table row, but I am in difficulty because I have never done with laravel yajra datatable html serverside. Any ideas, can anyone give me some advice on how to integrate a barcode in the table

Code snippet of problem

public function dataTable(QueryBuilder $query): EloquentDataTable
    {
        return (new EloquentDataTable($query))
            ->setRowId('id')
            ->addColumn();
    }

public function getColumns(): array
    {
        return [
            Column::make('BarCode')->addClass(''),
        ];
    }

<div class="d-flex justify-content-center">
   {!! DNS1D::getBarcodeHTML($product['product_code'], "C128",1.4,22) !!}
</div>
 <hr>
<div class="d-flex justify-content-center">
  {!! DNS2D::getBarcodeHTML($product['product_code'], 'QRCODE') !!}
</div>

System details

yajra commented 1 day ago

Use add column then set it as rawColumns:

->addColumn('barcode', fn(Product $product) => DNS2D::getBarcodeHTML($product['product_code'], 'QRCODE'));
->rawColumns(['barcode'])
markplus commented 1 day ago

Use add column then set it as rawColumns:

->addColumn('barcode', fn(Product $product) => DNS2D::getBarcodeHTML($product['product_code'], 'QRCODE'));
->rawColumns(['barcode'])

Thank you very much for the answer, if I wanted a print button only for the generated barcode is it possible to do it? I should print the barcode with a dymo