Yii Advanced Filters
The Yii Advanced Filters extension improves Yii's grid view filters by allowing users to enter more powerful search terms. Multiple filter expressions can be combined together when filtering a single column, allowing for complex filters to be applied.
By default, the extension will understand the following patterns when they are entered into a grid filter:
<td>The value must match the regular expression pattern.</td>
</tr>
<tr>
<td>
n1 <strong class="text-primary">to</strong> n2
</td>
<td>Numerically between n1 and n2 inclusive.</td>
</tr>
<tr>
<td>
<strong class="text-primary"><</strong>
n1
<strong class="text-primary"><=</strong>
n1
</td>
<td>Numerically less than [or equal to] n1.</td>
</tr>
<tr>
<td>
<strong class="text-primary">></strong>
n1
<strong class="text-primary">>=</strong>
n1
</td>
<td>Numerically greater than [or equal to] n1.</td>
</tr>
<tr>
<td>
<strong class="text-primary">=</strong> n1
</td>
<td>Numerically equal to n1.</td>
</tr>
<tr>
<td>
<strong class="text-success">!</strong> filter
</td>
<td>Invert any filter listed above with an exclamation
mark.</td>
</tr>
<tr>
<td>
filter1
<strong class="text-success">|</strong>
filter2
</td>
<td>The value must match at least one of the combined
filters.</td>
</tr>
<tr>
<td>
filter1
<strong class="text-success">&</strong>
filter2
</td>
<td>The value must match all of the combined filters.</td>
</tr>
</tbody>
Syntax | Description |
---|---|
word1 word2 word3 | All words must appear in any order. |
"search term" | The value must match the search term exactly. |
#search term# | The value must contain the exact search term. |
/regex/ |
For instance, the filters could be used and combined in the following ways:
Examples | |
---|---|
< 400 & !"" | Numerically less than 400 and not blank. |
=100 | =200 | =300 | Numerically equal to either 100, 200 or 300. |
gold & ! fool's & ! pyrite | Contains the word gold, but not fool's or pyrite. |
/^[A-Z][0-9]+$/ | A letter followed by one or more numbers (MySQL). |
! /[A-Z]/ | Does not contain any letters (MySQL). |
1 to 100 & ! . & /[02468]$/ | Even integers between 1 and 100. |
Note that with most delimiters the whitespace is optional, so <400&!"" and < 400 & ! "" are equivalent.