Skip to content

Commit 359aedf

Browse files
nidjo17paveljanda
authored andcommitted
fix FilterSelect applying
1 parent e7b0ceb commit 359aedf

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/DataSource/ArrayDataSource.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Ublaboo\DataGrid\Filter\FilterDateRange;
1616
use Ublaboo\DataGrid\Filter\FilterMultiSelect;
1717
use Ublaboo\DataGrid\Filter\FilterRange;
18+
use Ublaboo\DataGrid\Filter\FilterSelect;
1819
use Ublaboo\DataGrid\Filter\FilterText;
1920
use Ublaboo\DataGrid\Utils\DateTimeHelper;
2021
use Ublaboo\DataGrid\Utils\Sorting;
@@ -196,6 +197,10 @@ protected function applyFilter($row, Filter $filter)
196197
$value = (string) $value;
197198
$rowVal = (string) $row[$column];
198199

200+
if ($filter instanceof FilterSelect) {
201+
return $rowVal === $value;
202+
}
203+
199204
if ($filter instanceof FilterText && $filter->isExactSearch()) {
200205
return $rowVal === $value;
201206
}

tests/Cases/DataSources/BaseDataSourceTest.phpt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,16 @@ abstract class BaseDataSourceTest extends TestCase
188188
], $result);
189189
}
190190

191+
public function testFilterSelect(): void
192+
{
193+
$filter = new Ublaboo\DataGrid\Filter\FilterSelect($this->grid, 'a', 'b', ['John Red' => 'John Red'], 'name');
194+
$filter->setValue('John Red');
195+
196+
$this->ds->filter([$filter]);
197+
198+
Assert::equal([$this->data[5]], $this->getActualResultAsArray());
199+
}
200+
191201

192202
protected function getActualResultAsArray()
193203
{

0 commit comments

Comments
 (0)