Skip to content

Commit a218665

Browse files
authored
Merge pull request #628 from Laravel-Backpack/docs-for-datatable-widget
2 parents f1f1b8c + 7b217a3 commit a218665

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

7.x-dev/base-components.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,28 @@ Note that you can further customize this using custom attributes. If you define
4646

4747
<hr>
4848

49+
<a name="datatable"></a>
50+
### DataTable
51+
52+
Show a datatable _anywhere you want_, so the admin to easily list, filter, search and perform other operations on entries of an Eloquent model. The datatable component is a extension of a CrudController - so a CRUD for that entity needs to be already set up, and passed to this component as a parameter:
53+
54+
```html
55+
<x-datatable controller="\App\Http\Controllers\InvoiceCrudController" />
56+
```
57+
58+
The datatable will pick up everything that in your `setupListOperation()`. You can then further add/remove/configure functionality using the configuration closure:
59+
60+
```html
61+
<x-datatable
62+
controller="\App\Http\Controllers\InvoiceCrudController"
63+
<!-- optional -->
64+
:setup="function($crud, $parent) { if ($parent) { $crud->addClause('where', 'customer_id', $parent->id); } }"
65+
name="invoices"
66+
/>
67+
```
68+
69+
<hr>
70+
4971

5072
<a name="menu-separator"></a>
5173
### Menu Separator

7.x-dev/base-widgets.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,27 @@ class ChartjsPieController extends ChartController
349349

350350
<hr>
351351

352+
<a name="datatable"></a>
353+
### DataTable
354+
355+
Shows a datatable component from a particular CrudController. For more info about the configuration parameter, please see the [datatable component docs](/docs/{{version}}/base-components#datatable).
356+
357+
```php
358+
[
359+
'type' => 'datatable',
360+
'controller' => 'App\Http\Controllers\Admin\PetShop\InvoiceCrudController',
361+
'name' => 'invoices',
362+
'setup' => function($crud, $parent) {
363+
// you can use this closure to modify your CrudController definition.
364+
if ($parent) {
365+
$crud->addClause('where', 'owner_id', $parent->id);
366+
}
367+
}
368+
]
369+
```
370+
371+
372+
<hr>
352373

353374
<a name="div"></a>
354375
### Div

7.x-dev/upgrade-guide.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ No changes needed.
109109
<a name="views"></a>
110110
### Views
111111

112-
No changes needed.
112+
**List Operation View** - The List Operation view got a huge change. We decoupled the datatable from the view, so that you can use the table anywhere you would like.
113+
Most of the code is still identical but moved to `datatable.blade.php`. The `list.blade.php` view now only includes the mentioned datatable component.
114+
115+
If you had customized the `list.blade.php` you should move your customizations to `datatable.blade.php`.
113116

114117
<a name="security"></a>
115118
### Security

0 commit comments

Comments
 (0)