Skip to content

Commit 6b2dd87

Browse files
authored
Merge pull request #49 from lelinhtinh/master
Trigger the search
2 parents f443075 + 4751172 commit 6b2dd87

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

src/Column.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ class Column
2323
*/
2424
public $hidden = false;
2525

26+
/**
27+
* Column seachable
28+
*
29+
* @var bool
30+
*/
31+
public $forceSearch = false;
32+
2633
/**
2734
* Callback function
2835
*
@@ -72,12 +79,12 @@ public function value($row): string
7279
/**
7380
* Set visibility of the column.
7481
*/
75-
public function hide(): void
82+
public function hide($searchable = false): void
7683
{
7784
$this->hidden = true;
85+
$this->forceSearch = $searchable;
7886
}
7987

80-
8188
/**
8289
* @return bool
8390
*/
@@ -115,6 +122,6 @@ public function data(): string
115122
*/
116123
public function searchValue(): string
117124
{
118-
return $this->attr['search']['value'];
125+
return $this->attr['search']['value'] ?? '';
119126
}
120127
}

src/Datatables.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,19 +140,12 @@ public function getQuery(): Query
140140
}
141141

142142
/**
143-
* @param array $columns
143+
* @param string $column
144144
* @return Datatables
145145
*/
146-
public function hide(...$columns): Datatables
146+
public function hide(string $column, $searchable = false): Datatables
147147
{
148-
foreach ($columns as $column) {
149-
if (\is_array($column)) {
150-
$this->hide(...$column);
151-
} else {
152-
$this->columns->getByName($column)->hide();
153-
}
154-
}
155-
148+
$this->columns->getByName($column)->hide($searchable);
156149
return $this;
157150
}
158151

src/Iterators/GlobalSearchableColumns.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ class GlobalSearchableColumns extends FilterIterator
1717
*/
1818
public function accept(): bool
1919
{
20-
return !$this->current()->hidden && $this->current()->isSearchable();
20+
return ($this->current()->forceSearch || (!$this->current()->hidden && $this->current()->isSearchable()));
2121
}
2222
}

0 commit comments

Comments
 (0)