yajra / laravel-datatables-editor

Laravel DataTables Editor Integration.
https://yajrabox.com/docs/laravel-datatables/editor-installation
MIT License
115 stars 14 forks source link

Bug on Editor / Tutorial (following issue https://github.com/yajra/laravel-datatables-buttons/issues/101) #46

Closed Benoit75 closed 4 years ago

Benoit75 commented 4 years ago

Summary of problem or feature request

Hello This issue is following https://github.com/yajra/laravel-datatables-buttons/issues/101 (i can't reopen it)

On a fresh install following yajra/Datatables Quick starter (ok) and Editor/Tutorial. There is a JS error : Uncaught Cannot extend unknown button type: selected

The error is generate by two editor button in UsersDatatables.php

Button::make('edit')->editor('editor'),
Button::make('remove')->editor('editor'),

Any thought ? Thank's

Benoit75 commented 4 years ago

Well here seems to be the problem : 1) We need to load the select plugin (cf https://datatables.net/download/) @yajra i can't find why it does not load with others plugin? 2) in builder set select @ true 3) in builder set the row id (https://datatables.net/manual/tech-notes/14)

So our code is now

views/layouts/app.blade.php, just before < /head>

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/select/1.3.1/css/select.dataTables.min.css"/>
</head>

views/layouts/app.blade.php, just before < /body>

<script type="text/javascript" src="https://cdn.datatables.net/select/1.3.1/js/dataTables.select.js"></script>
    @stack('scripts')
</body>

app/DataTables/UsersDataTable.php

return $this->builder()
                    ->setTableId('users-table')
                    ->columns($this->getColumns())
                    ->minifiedAjax()
                    ->dom('Bfrtip')
// ---------------------------------------------
                    ->select(true)
//---------------------------------------------
                    ->orderBy(1)
                    ->buttons(
                        Button::make('create')->editor('editor'),
                        Button::make('edit')->editor('editor'),
                        Button::make('remove')->editor('editor'),
                        Button::make('export'),
                        Button::make('print'),
                        Button::make('reset'),
                        Button::make('reload')
                    )
                    ->editor(
                        Editor::make()
                            ->fields([
                                Fields\Text::make('name'),
                                Fields\Text::make('email'),
                                Fields\Password::make('password'),
                            ])
//---------------------------------------------
                            ->idSrc(['id'])
//---------------------------------------------
                    );

Enjoy !

Benoit75 commented 4 years ago

@yajra said in [https://github.com/yajra/laravel-datatables-buttons/issues/101] datatables.net-select-bs4 was missing ! Work's fine know