本文介绍了Yii ClistView分页不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Clistview分页无法正常工作.我尝试了所有事情,但仍然没有成功.这是我的模型函数:

My Clistview Pagination is not working properly.I tried every thing but still not getting success.Here is my model function:

public function getallone()
{
    $criteria = new CDbCriteria;
    $criteria->select   =   "t.id";
    $criteria->condition = "t.featured=1 AND t.status = 1";
            return new CActiveDataProvider($this, array(
        'criteria'=>$criteria,
                'pagination' => array('pageSize' => 25),

    ));
}

我仍然每页只得到10个项目,但我要25.I尝试2个项目,但它也无法正常工作.怎么了?找不到了.

Am still getting only 10 items per page but i want 25.I tried to 2 items but its also not working. Whats wrong with that?Didnt find.

这是我的查看代码:

<?php $this->widget('zii.widgets.CListView', array(
        'dataProvider'=>$model->getallone(),
        'itemView'=>'_allone',

        'enablePagination' => true,
        )); ?>

推荐答案

您应该尝试使用此方法以获得更好的分页选项

You shoud try this for better pagination option

$condition='type=:type';
$dataArray[':type']=$type;
$dataProvider=new CActiveDataProvider('modelname', array(
        'criteria'=>array(
         'select'=>'*',
            'condition'=>$condition,
            'params'=>$dataArray,
            'order'=>'id DESC',
            'offset'=>($page-1)*$limit,
            'limit'=>$limit,
         ),
        'pagination'=>array(
            'pageSize'=>$limit,

    ),
    ));

  $totalActivity= $dataProvider->getTotalItemCount();

http://www.yiiframework.com/doc/api/1.1/CActiveDataProvider 供参考

这篇关于Yii ClistView分页不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 13:34