You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+28Lines changed: 28 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -413,6 +413,34 @@ class CallbackDemoTable extends LivewireDatatable
413
413
}
414
414
```
415
415
416
+
### Default Filters
417
+
418
+
If you want to have a default filter applied to your table, you can use the `defaultFilters` property. The `defaultFilter` should be an Array of column names and the default filter value to use for. When a persisted filter (`$this->persistFilters` is true and session values are available) is available, it will override the default filters.
419
+
420
+
In the example below, the table will by default be filtered by rows where the _deleted_at_ column is false. If the user has a persisted filter for the _deleted_at_ column, the default filter will be ignored.
421
+
422
+
```php
423
+
class CallbackDemoTable extends LivewireDatatable
424
+
{
425
+
public $defaultFilters = [
426
+
'deleted_at' => '0',
427
+
];
428
+
429
+
public function builder()
430
+
{
431
+
return User::query()->withTrashed();
432
+
}
433
+
434
+
public function columns()
435
+
{
436
+
return [
437
+
Column::name('id'),
438
+
BooleanColumn::name('deleted_at')->filterable(),
439
+
];
440
+
}
441
+
}
442
+
```
443
+
416
444
### Views
417
445
You can specify that a column's output is piped directly into a separate blade view template.
418
446
- Template is specified using ususal laravel view helper syntax
0 commit comments