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: docs/misc/multiple-tables.md
+10-47Lines changed: 10 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,62 +33,25 @@ If you need the above, you should make them different components like so:
33
33
<livewire:pending-users-table />
34
34
```
35
35
36
-
## Introduction
37
-
38
-
By default, your table has a name of `table`, as well as an internal array called `$table` which saves its state to the query string.
39
-
40
-
The query string would look like this:
41
-
42
-
```php
43
-
// Under the hood
44
-
public array $queryString = [
45
-
'table' => [
46
-
'search' => null,
47
-
'sort' => [],
48
-
...
49
-
],
50
-
]
51
-
```
52
-
53
-
In order to have multiple tables on the same page, you need to tell it how to save the state of each table.
54
-
55
-
## Setting the table name and data
56
-
57
-
If you have multiple tables on the same page and you want them to have independent state saved in the query string, you must set a table name and data array.
58
-
59
-
```php
60
-
public string $tableName = 'users';
61
-
public array $users = [];
62
-
```
63
-
64
-
The data array must be the same name as the table name. This data array will remain blank, I tried to create it dynamically in the query string but Livewire doesn't support that, so you have to define it yourself. It is a workaround until Livewire supports dynamic properties for the query string.
36
+
## Disabling the query string for multiple of the same component
65
37
66
-
Your query string will now look like this:
38
+
If you must have multiple of the same component on the same page, you should disable the query string for those components so the query string state does not get replaced by one or the other:
67
39
68
40
```php
69
-
// Under the hood
70
-
public array $queryString = [
71
-
'users' => [
72
-
'search' => null,
73
-
'sort' => [],
74
-
...
75
-
],
76
-
// Other tables
77
-
'roles' => [
78
-
'search' => null,
79
-
'sort' => [],
80
-
...
81
-
],
82
-
]
41
+
public function configure(): void
42
+
{
43
+
$this->setQueryStringDisabled();
44
+
}
83
45
```
84
46
85
-
## Disabling the query string for multiple of the same component
47
+
## Disabling column selection for multiple of the same component
86
48
87
-
If you must have multiple of the same component on the same page, you should disable the query string for those components so the query string state does not get replaced by one or the other:
49
+
You should also disable the columns selection for those components so the query string and session state does not get replaced by one or the other:
0 commit comments