0

我有这个使用 CActiveDataProvider 的查询。我的表包含 15 条满足条件的记录,但由于某种原因,只显示了 10 条记录。这里可能缺少什么。

$prov2 = new CActiveDataProvider('BaseSiReceivedItem', array(
            'criteria' => array(
            'condition' => 'iar_no = 0'
            )));

echo count($prov2->data);
4

3 回答 3

0

The listview widget's pageSize value in the view file might be overriding the pageSize value in the controller (if it's not set, the default value may override the controller).

Or, you could create a custom list view like this:

extensions/CustomListView.php

<?php
Yii::import('zii.widgets.CListView');

class CustomListView extends CListView {

    public function init() {
        if ($this->dataProvider !== null)
            $this->dataProvider->pagination->pageSize = 30;
        parent::init();
    }
}

and use it in your view: views/{model}/index.php

<?php $this->widget('CustomListView', array(
        'dataProvider' => $dataProvider,
        'itemView' => '_view'
)); ?>
于 2013-10-01T06:33:54.067 回答
0
'pagination'=>array(
'pageSize'=>15,
)

现在显示你是 15 吗?

这个关于 itemCounts 的链接也可能会有所帮助。来自 DataProvider 的 Yii 分页变量

于 2013-10-01T00:38:18.510 回答
0

我也遇到过这个问题,只列出 10 个项目,同时从我的列表视图中禁用分页。当时我使用了以下代码,并且列出了所有项目:)

$data = new CActiveDataProvider('ProviderPortfolioSet', array('criteria' => $criteria, 'pagination' => false));
于 2013-11-11T11:35:21.357 回答