a terrible bug about CGridView

I test to used CGridView。

But i meet some bugs. :unsure:

The First:

$criteria=new CDbCriteria;









return new CActiveDataProvider(get_class($this), array(


'pagination' => array( 'pageSize' => 30 ), 


THE $this->Score’s default value is 0.

I don’t set it at all~~~

please look at this photo:



The default value is 0 .and it filter the data which score unequal to 0

If I delete it:


It were be okey~~~~


If ‘0’ is showing up in the filter input for score, then it must be being set to the $model that you use as the basis for your search somehow, either as a GET parameter (in which case it is massively assigned to the model in the action, presuming you are using the default Gii-generated code), or by the model itself.

What kind of variable in your model is score? Does it directly correspond to a table column, or is it coded in the model?

You should include the url that generates this page (without making any ajax calls), the code in your action, the code in your view and your model code.

Could be that you have defined in the database a default value for that field… so when you create a model this field gets it’s default value…

to solve this… call unsetAttributes() - http://www.yiiframework.com/doc/api/1.1/CModel#unsetAttributes-detail

$model = new YourModel;


using something else like enum or a number larger than 0, the world will in peace. :slight_smile:


THS for every one~~~

That’s kind of you ~~

I use


solved it!

Hope it can help another man who meet the same problem! ;D

Glad you got it working.

Can you confirm though that you had a default value in your database, just so that if other people come across this problem they know the reason?