Cactivedataprovider With Pagesize


I am trying to display my "folder models" in a yii gridview. A "folder model" can contain one or more "file models", so I added a relation.

Now to the problem: I use the standard yii function to search for folders and display them with the help of a CActiveDataProvider in a CGridView:

//Folder model

public function search() {

    $criteria=new CDbCriteria;

    $criteria->with = array('files');

    $criteria->together = true;

    $criteria->compare('name', $this->name, true);

    $criteria->compare('', $this->file_name, true);

    return new CActiveDataProvider($this, array('criteria'=>$criteria, 'pagination'=>array('pageSize'=>10)));


The problem is: Because of the "with files", the pagination does not work correctly. Page 1 of my CGridView shows 10 items, page 2 only 3, page 3 again 10, page 4 only 2. How can I fix that? I need the "with" relation to display only folders that contain a specific file name.

Hi incendium,

Please take a look at this: