This is intended to enable filtering by columns that are not displayed.
<table class="gridView__table" id="{$view->getID()}_table"{if !$view->countRows()} hidden{/if}>
<thead>
<tr class="gridView__headerRow">
- {foreach from=$view->getColumns() item='column'}
+ {foreach from=$view->getVisibleColumns() item='column'}
<th
class="gridView__headerColumn {$column->getClasses()}"
data-id="{$column->getID()}"
{foreach from=$view->getRows() item='row'}
<tr class="gridView__row" data-object-id="{$view->getObjectID($row)}">
- {foreach from=$view->getColumns() item='column'}
+ {foreach from=$view->getVisibleColumns() item='column'}
<td class="gridView__column {$column->getClasses()}">
{unsafe:$view->renderColumn($column, $row)}
</td>
return $this->columns;
}
+ /**
+ * @return GridViewColumn[]
+ */
+ public function getVisibleColumns(): array
+ {
+ return \array_filter($this->getColumns(), fn($column) => !$column->isHidden());
+ }
+
public function getColumn(string $id): ?GridViewColumn
{
foreach ($this->getColumns() as $column) {
private bool $sortable = false;
private string $sortById = '';
private ?IGridViewFilter $filter = null;
+ private bool $hidden = false;
private function __construct(private readonly string $id) {}
return false;
}
+
+ public function hidden(bool $hidden = true): static
+ {
+ $this->hidden = $hidden;
+
+ return $this;
+ }
+
+ public function isHidden(): bool
+ {
+ return $this->hidden;
+ }
}