Skip to content

Commit b645338

Browse files
committed
add more controls to tabl
1 parent f1e1eae commit b645338

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

package-ui/src/Table.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,18 @@ public function defaultSorting(?Closure $using): static
157157
return $this;
158158
}
159159

160+
/**
161+
* Disable sorting on the table.
162+
*/
163+
public function withoutSorting(): static
164+
{
165+
if ($this->columns instanceof ColumnCollection) {
166+
$this->columns->all()->each(fn (Column $column) => $column->withoutSorting());
167+
}
168+
169+
return $this;
170+
}
171+
160172
/**
161173
* Do not send resource to the frontend.
162174
*/
@@ -223,6 +235,16 @@ public function withFilters(array $filters): static
223235
return $this;
224236
}
225237

238+
/**
239+
* Disable filtering on the table.
240+
*/
241+
public function withoutFilters(): static
242+
{
243+
$this->filter->clearWidgets();
244+
245+
return $this;
246+
}
247+
226248
/**
227249
* Configure search callback on the source.
228250
*/
@@ -233,6 +255,16 @@ public function searchable(?Closure $using): static
233255
return $this;
234256
}
235257

258+
/**
259+
* Disable search on the table.
260+
*/
261+
public function withoutSearch(): static
262+
{
263+
$this->searchUsing = null;
264+
265+
return $this;
266+
}
267+
236268
/**
237269
* Set available per page options.
238270
*/

package-ui/src/Table/Column.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,17 @@ public function getDefaultSortDirection(): ?Direction
547547
return $this->defaultDirection;
548548
}
549549

550+
/**
551+
* Disable sorting on the column.
552+
*/
553+
public function withoutSorting(): static
554+
{
555+
$this->sortingName = null;
556+
$this->sortableUsing = null;
557+
558+
return $this;
559+
}
560+
550561
/**
551562
* Retrieve name of the sorting for the column.
552563
*/

package-ui/src/Table/Filter.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ public function widget(FilterWidget $filter): static
3535
return $this;
3636
}
3737

38+
/**
39+
* Remove the filter widgets.
40+
*/
41+
public function clearWidgets(): static
42+
{
43+
$this->widgets = [];
44+
45+
return $this;
46+
}
47+
3848
/**
3949
* Check whether given filter is applied.
4050
*/

0 commit comments

Comments
 (0)