Cgridview Show The Results Only When Filtered

I want my CGridView show the results only when filtered, how can I do this? thank you

The filter values are submitted by $_GET to your actionAdmin, where you assign the submitted attributes to your model.

So you have to check if there are no empty attribute values assigned to your model in the actionAdmin:

public function actionAdmin()


		$model=new MyModel('search');

		$model->unsetAttributes();  // clear any default values


		if (isset($_GET['MyModel'])) 



                        foreach($_GET['MyModel'] as $key=>$value) //or foreach($model->attributes as ...)











                        'isFiltered'=>isFiltered, //submit to your view



In your view you can assign a CArrayDataProvider with no data instead the model->search() if you want to show no data.



	'dataProvider'=>$isFiltered ? $model->search() : new CArrayDataProvider(array()),



It works like a charm!

Thank you very much Joblo