Skip to content

Commit 643f8e1

Browse files
committed
Add back refresh property
1 parent 70648ef commit 643f8e1

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ In the component you have access to `$this->selectedRowsQuery` which is a **Buil
293293

294294
### Options
295295

296-
There are a couple class level properties you can set:
296+
There are some class level properties you can set:
297297

298298
| Property | Default | Usage |
299299
| -------- | ------- | ----- |
@@ -302,6 +302,7 @@ There are a couple class level properties you can set:
302302
| $showPagination | true | Show the pagination |
303303
| $showSorting | true | Show the sorting pills |
304304
| $showFilters | true | Show the filter pills |
305+
| $refresh | false | Whether or not to refresh the table at a certain interval. false = off, int = ms, string = functionCall |
305306

306307
#### Using more than one table on a page
307308

resources/views/tailwind/datatable.blade.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
<div class="flex-col space-y-4">
1+
<div
2+
@if (is_numeric($refresh)) wire:poll.{{ $refresh }}.ms @elseif(is_string($refresh)) wire:poll="{{ $refresh }}" @endif
3+
class="flex-col space-y-4"
4+
>
25
@if ($showSorting && count($sorts))
36
<div wire:key="sort-badges" class="p-6 md:p-0">
47
<small class="text-gray-700">@lang('Applied Sorting'):</small>

src/DataTableComponent.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ abstract class DataTableComponent extends Component
5757
*/
5858
public bool $showFilters = true;
5959

60+
/**
61+
* Whether or not to refresh the table at a certain interval
62+
* false is off
63+
* If it's an integer it will be treated as milliseconds (2000 = refresh every 2 seconds)
64+
* If it's a string it will call that function every 5 seconds.
65+
*
66+
* @var bool|string
67+
*/
68+
public $refresh = false;
69+
6070
/**
6171
* Name of the page parameter for pagination
6272
* Good to change the default if you have more than one datatable on a page.

0 commit comments

Comments
 (0)