Yii CGrid pagination and sorting with CArrayDataProvider doesnt work

I built a custom function in my model and return the raw data:






return $rows;


$campModel = $model->function..

I then use those rows in CArrayDataProvider:

$dataProvider=new CArrayDataProvider($campModel);

Finally i’m trying to view using CGrid:

$this->widget('zii.widgets.grid.CGridView', array(



I’m guessing this has to do with the way CGrid is paging…but i’m lost Thanks for the help :)

Try this:

$dataProvider = new CArrayDataProvider($campModel, array(

   'sort' => array(

      'attributes' => array('id', 'title'); //What you want to sort ?

      'defaultOrder' => array('title' => false); //false means ASC


    'pagination' => array(

        'pageSize' => 5;