Skip to content

Commit 6146713

Browse files
committed
Added option for single column sorting
1 parent bb5227f commit 6146713

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

CHANGELOG.md

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

55
## [Unreleased]
66

7+
### Added
8+
9+
- Added option for single column sorting only
10+
711
## [1.3.1] - 2021-04-26
812

913
### Added

src/Traits/WithSorting.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@
1010
trait WithSorting
1111
{
1212
public bool $showSorting = true;
13+
public bool $singleColumnSorting = false;
1314
public array $sorts = [];
1415
public array $sortNames = [];
1516
public array $sortDirectionNames = [];
1617

1718
public function sortBy(string $field): ?string
1819
{
20+
if ($this->singleColumnSorting && count($this->sorts) && !isset($this->sorts[$field])) {
21+
$this->sorts = [];
22+
}
23+
1924
if (! isset($this->sorts[$field])) {
2025
return $this->sorts[$field] = 'asc';
2126
}

0 commit comments

Comments
 (0)