-
-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial Commit * Fix styling * Further adjustments * Fix styling * Improve Tests - Extend PetsTable * Fix styling --------- Co-authored-by: lrljoe <[email protected]>
- Loading branch information
Showing
17 changed files
with
250 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
--- | ||
title: Hiding The Table (beta) | ||
weight: 8 | ||
--- | ||
|
||
You may wish to hide the table on load. To do so, you should use the following in the mount method. Note that this is in mount, not boot nor configure! | ||
|
||
```php | ||
public function mount() | ||
{ | ||
$this->setShouldBeHidden(); | ||
} | ||
``` | ||
|
||
### Using Events To Display/Hide | ||
|
||
For example, you may have a "Sales" table that you wish to hide by default: | ||
```php | ||
class SalesTable extends DataTableComponent | ||
{ | ||
public string $tableName = 'sales'; // Required to keep the call specific | ||
|
||
public function mount() | ||
{ | ||
$this->setShouldBeHidden(); // Defaults the table to be hidden, note that this is in MOUNT and not CONFIGURE | ||
} | ||
|
||
// Configure/Columns/Filters etc | ||
} | ||
``` | ||
|
||
The Table allows for different approaches, out-of-the-box it supports the more efficient client-side listeners. | ||
|
||
However - should you wish to use Livewire listeners in your table component, for example if you wish to pass more detail into the Table then you can: | ||
|
||
```php | ||
#[On('showTable.{tableName}')] | ||
public function showTable(): void | ||
{ | ||
$this->setShouldBeDisplayed(); | ||
} | ||
|
||
#[On('hideTable.{tableName}')] | ||
public function hideTable(): void | ||
{ | ||
$this->setShouldBeHidden(); | ||
} | ||
``` | ||
|
||
|
||
### Secondary Table | ||
Below are the two approaches. Note that you can customise the Livewire "On" to pass additional details should you wish. | ||
|
||
#### Using Client Side Listeners | ||
```php | ||
Column::make('Show') | ||
->label( | ||
fn($row, Column $column) => "<button x-on:click=\"\$dispatch('show-table',{'tableName': 'sales' })\">Show Sales Table</button>" | ||
)->html(), | ||
Column::make('Hide') | ||
->label( | ||
fn($row, Column $column) => "<button x-on:click=\"\$dispatch('hide-table',{'tableName': 'sales' })\">Hide Sales Table</button>" | ||
)->html(), | ||
``` | ||
|
||
|
||
#### Using Livewire "On" Style Listeners: | ||
```php | ||
Column::make('Show') | ||
->label( | ||
fn($row, Column $column) => "<button x-on:click=\"\$dispatch('showTable.sales')\">Show Sales Table</button>" | ||
)->html(), | ||
Column::make('Hide') | ||
->label( | ||
fn($row, Column $column) => "<button x-on:click=\"\$dispatch('hideTable.sales')\">Hide Sales Table</button>" | ||
)->html(), | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.