grid filter compare operators and default value to 0

Hi all,

I had two problems.

  1. my table has a column called basePrice. It is a decimal (15,3) in mysql. The thing is in yii 1.1.x, I can use compare and the operator is automatically handled. However, I did not see the equivalent in yii2. can someone help?

  2. the other problem is that this field, basePrice will be set to 0 every time I make a filter to other field. this is annoying since will effect the result of the filtered gridview.

Thanks in advance for your help.



for the second question, my current workaround is

    if (!empty($this->basePrice)) {

                $query->andFilterWhere(['basePrice' => $this->basePrice]);

            } else {

                $this->basePrice = null;


basePrice seems to be set to 0 after compared using andFilterWhere. anyone has better solution? this one looks ugly.

I need to work more on the operations.