Is it possible to define custom filter that does not filter out specific rows? I’ve orderlocked - field in the database and all rows that have value 1 for this I would like to show on the GridView even if it would be otherwise filtered out. Thanks.
Is it possible to define custom filter that does not filter out specific rows? I’ve orderlocked - field in the database and all rows that have value 1 for this I would like to show on the GridView even if it would be otherwise filtered out. Thanks.
What does your Query/DataProvider code look like at the moment?
Almost the same as it comes with basic-configuration, haven’t tweaked that much. Something specific you want to know?
You could do something like
$query->orWhere(['orderlocked' => 1])
Thanks but this creates WHERE (orderlocked
=1) AND statement to the query and will show only the mentioned rows. How to create OR statement?
That’s odd. The documentation clearly states
http://www.yiiframework.com/doc-2.0/yii-db-querytrait.html#orWhere()-detail
I’ve found that the order in which you place ->*Where() statements matters. I use
$announceModel = Announcement::find()
->where(['>=', 'end_date', time()])
->orWhere('end_date IS NULL')
->andWhere(['<=', 'start_date', time()])
->orderBy('start_date DESC')
->all();
This gives me every announcement that the ‘start_date’ has passed AND ‘end_date’ has not come OR ‘end_date’ is NULL (No End Date).
It took awhile to get the order of where() clauses in the right order.
Still having problems with ->select() of a field from a ->joinWith() relation.
Indeed, it’s odd. Perhaps the order means something here, I don’t know. I’ve spent now quite some trying to fix this issue.
This works (finally):
if ($query->where)
{
$query->orFilterWhere(['=', 'orders.orderlocked', 1]);
}