How to use export buttons in yajrabox datatables laravel?

1.2k views Asked by At

I think I'm doing everything documentation says but I'm getting this error and can't find solution for that

dataTables.buttons.min.js:16 Uncaught Buttons: Too many iterations

Cnds:

<link rel="stylesheet" href="//cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.0.3/css/buttons.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.12/css/dataTables.bootstrap.min.css" />


<script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.12/js/dataTables.bootstrap.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.0.3/js/dataTables.buttons.min.js"></script>
<script src="{{ asset('vendor/datatables/buttons.server-side.js') }}"></script>
@stack('scripts')

Yajrabox Database model methods:

public function html()
{
    return $this->builder()
                ->setTableId('student-table')
                ->columns($this->getColumns())
                ->minifiedAjax()
                ->dom('Bfrtip')
                ->orderBy(1)
                ->buttons(
                    Button::make('cvs'),
                    Button::make('excel')
                );
}


protected function getColumns()
{
    return [
        Column::make('first_name'),
        Column::make('last_name'),
    ];
}
1

There are 1 answers

1
EvilBurrito On BEST ANSWER

At firs I see you wrote "cvs" instead of "csv"

Are you also adding the datatable js/css in your bootstrap.js file? If yes, then you don't need all these extra cdn scripts.

Change your ->buttons call to

->parameters([
   'buttons' => ['csv'],
]);