Skip to content

Commit e8d99e2

Browse files
committed
revert multiple-tables.md, update changelog
1 parent f1cdb4d commit e8d99e2

File tree

2 files changed

+51
-15
lines changed

2 files changed

+51
-15
lines changed

CHANGELOG.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@ All notable changes to `laravel-livewire-tables` will be documented in this file
44

55
## [Unreleased]
66

7-
## [column-select-dev] - 2022-05-14
7+
## [column-select-dev] - 2022-05-16
88

99
### Added
1010

1111
- Added functionality to bookmark or deep link column selection
12-
- Added functionality to identify different datatable components as unique in column selection and filter arrays
13-
14-
### Changed
15-
16-
- Simplified misc/multiple-tables.md in docs where additional steps are no longer needed. (Original steps still work and lead to same result)
12+
- Added functionality to identify different datatable components as unique in column selection
13+
- Added Funcitonality to configure query string alias
14+
- Added Funcitonality to configure session key for column selection (dataTableFingerprint)
1715

1816
## [2.7.0] - 2022-05-07
1917

docs/misc/multiple-tables.md

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,62 @@ If you need the above, you should make them different components like so:
3333
<livewire:pending-users-table />
3434
```
3535

36-
## Disabling the query string for multiple of the same component
36+
## Introduction
3737

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:
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:
3941

4042
```php
41-
public function configure(): void
42-
{
43-
$this->setQueryStringDisabled();
44-
}
43+
// Under the hood
44+
public array $queryString = [
45+
'table' => [
46+
'search' => null,
47+
'sort' => [],
48+
...
49+
],
50+
]
4551
```
4652

47-
## Disabling column selection for multiple of the same component
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
4856

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:
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.
65+
66+
Your query string will now look like this:
67+
68+
```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+
]
83+
```
84+
85+
## Disabling the query string for multiple of the same component
86+
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:
5088

5189
```php
5290
public function configure(): void
5391
{
54-
$this->setColumnSelectStatus(false);
92+
$this->setQueryStringDisabled();
5593
}
5694
```

0 commit comments

Comments
 (0)