I’m facing a strange behavior with CListView when my CActiveData include à with criteria the pagination isn’t working anymore, I can change the page but the data doesn’t change ??.
$dataProvider = new CActiveDataProvider('Something', array(
'with' => array('somethingElse'),
)); // PAGINATION DOESN'T WORK
$dataProvider = new CActiveDataProvider('Something'); // WITH NOTHING
)); // PAGINATION WORK
/* WHY <img src='http://www.yiiframework.com/forum/public/style_emoticons/default/huh.gif' class='bbc_emoticon' alt='???' /> */
$dataProvider=new CActiveDataProvider('Post', array(
'criteria'=>array(
'condition'=>'status=1',
'order'=>'create_time DESC',
'with'=>array('author'),
),
'countCriteria'=>array(
'condition'=>'status=1',
// 'order' and 'with' clauses have no meaning for the count query
),
'pagination'=>array(
'pageSize'=>20,
),
));
// $dataProvider->getData() will return a list of Post objects
If the relationship between Something and SomethingElse is one-to-many (i.e. one Something has many SomethingElse), is it possible that ‘SomethingElse’ is leading to the repetition of data from the Something model?
If that isn’t the problem, then post the ‘_view.php’ code, the relations part of both the Something and SomethingElse models and the code for the function in which you are defining the DataProvider.
I think BlkRaven is right, that happens with a one-to-many with in gridview. The problem is that it runs a count before pagination, gets a total that includes the with’d results, and gets a total number of posts that are more than you have. If you’re using together=>true, you could set it to false.