无法在 CGridView 中为寻呼机设置 pageSize - Yii [英] Unable to set pageSize for pager in CGridView - Yii

查看:28
本文介绍了无法在 CGridView 中为寻呼机设置 pageSize - Yii的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在 CGridView 中设置 pageSize 属性,但没有成功.顺便说一下,目前共有 2 个项目,我只想在 1 页上显示 1 个.谢谢.

I am trying to set the pageSize property of pager in CGridView but in vain. By the way currently there are total of 2 items, i want to display only 1 on 1 page. Thanks.

<?php $this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'user-grid',
    'pager' => array(
        'pageSize' => 1,
    ),
    'dataProvider'=>$model->search(),
    'filter'=>$model,
    'columns'=>array(
        'id',
        'username',
        'email',
        'pass',
        'type',
        'date_entered',
        array(
            'class'=>'CButtonColumn',
        ),
    ),
)); ?>

推荐答案

从视图中删除以下内容

 'pager' => array(
        'pageSize' => 1,
    ),

在模型搜索方法的 dataprovider 数组中添加此代码

inside the dataprovider array in your model search method add this code

$dataProvider = new CActiveDataProvider('your_model', array(
                'pagination'=>array(
                        'pageSize'=>your_page_size,
                ),
                'criteria'=>$criteria,
        ));

这篇关于无法在 CGridView 中为寻呼机设置 pageSize - Yii的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆