In my case, I'd like the user's input to apply to both children.
Example: I have a datagrid for invoices and there's a column for Client (every invoice belongs to a specific client) - when the user filters by client, I want the filter to search on the client's Id and client's Name.
No, you can't use an Or, because which of its children would the user's input apply to?
What are you trying to accomplish? Sometimes there are workarounds we can come up with.
In my case, I'd like the user's input to apply to both children.
Example: I have a datagrid for invoices and there's a column for Client (every invoice belongs to a specific client) - when the user filters by client, I want the filter to search on the client's Id and client's Name.
Here is what you could do:
<?php
class QDGConditionOr extends QQConditionComparison {
protected $arrConditions;
public function __construct(/* list of QQConditionComparison objects*/) {
$this->arrConditions = func_get_args();
}
public function UpdateQueryBuilder(QQueryBuilder $objBuilder) {
foreach ($this->arrConditions as $condition) {
$condition->mixOperand = $this->mixOperand;
}
QQ::OrCondition($this->arrConditions)->UpdateQueryBuilder($objBuilder);
}
}
?>
then when setting up the data grid
<?php$col->Filter = new QDGConditionOr(QQ::Like(QQN::Client()->Id, null), QQ::Like(QQN::Client()->Name, null));
?>
Vakopian, thanks! It's working great!
One thing though: unlike the default text filters, this one only works on exact matches and won't search in substrings. Example:
client id is "1" and name is "John Doe", if I search for "1" or "John Doe" I get a match, but if I search for "Doe" no matches are returned.
Where can I change this behaviour? There must be a place to add some wildcards "%", right?
Yes, you can use
<?php$col->FilterPrefix = '%';
$col->FilterPostfix = '%';
?>
perfect! thank you