How to use CActiveDataProvider with already defined scopes?

I have created some model and some parameterized named scopes in it. And now i want to add some filtering options to data, displaying by CGridView, collected by CActiveDataProvider. I certainly can write something like this:




$dataProvider=new CActiveDataProvider('MyModel', array(

 'criteria'=>array(

  'condition'=>'param=:param',

   'params'=>array(

    ':param'=>$param,

...



but i don’t want to duplicate already written conditions, defined in scopes. Now i use this:




$dataProvider->criteria->mergeWith(MyModel::model()->param($param)->getDbCriteria());



but maybe there is a better way to do this?

You could try my extension CArrayDataProvider. It takes objects that can come from any array (scopes or child objects) and passes it over to CListView or CGridView.

Sorting and Pagination is not yet supported at this time, but it will be in the next version.

Thanks, i’ll try it