Antonio Ramirez, on 09 November 2010 - 06:35 PM, said:
I agree!
If you want more filtering, consider checking out the datafilter extension:
http://www.yiiframew...sion/datafilter
Posted 09 November 2010 - 06:50 PM
Antonio Ramirez, on 09 November 2010 - 06:35 PM, said:
Posted 10 November 2010 - 03:46 AM
Antonio Ramirez, on 09 November 2010 - 06:35 PM, said:
Posted 10 November 2010 - 03:41 PM
Posted 05 April 2011 - 02:14 PM
Posted 06 April 2011 - 01:39 AM
Posted 30 April 2011 - 12:31 AM
<?php $pageSize=Yii::app()->user->getState('pageSize',Yii::app()->params['defaultPageSize']); ?>
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'user-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'summaryText'=>'Displaying {start}-{end} of {count} result(s). ' .
CHtml::dropDownList(
'pageSize',
$pageSize,
array(5=>5,20=>20,50=>50,100=>100),
array('class'=>'change-pageSize')) .
' rows per page',
'columns'=>array(
'id',
'username',
'password',
'email',
array(
'class'=>'CButtonColumn',
),
),
)); ?>
<?php Yii::app()->clientScript->registerScript('initPageSize',<<<EOD
$('.change-pageSize').live('change', function() {
$.fn.yiiGridView.update('user-grid',{ data:{ pageSize: $(this).val() }})
});
EOD
,CClientScript::POS_READY); ?>
Posted 11 August 2011 - 04:29 PM
Posted 12 August 2011 - 01:01 AM
Posted 12 August 2011 - 05:04 AM
<?php
/*
* Project :
* Date : Jul 1, 2011 10:20:59 AM
* Author : matt.cheale
* File : MGridView.php
*/
Yii::import( 'zii.widgets.grid.CGridView' );
/**
* Extends CGridView making pagers at the top and bottom default and adding in a pageSize
* form element.
*
* @author matt.cheale
* @since Jul 1, 2011
*/
class MGridView extends CGridView
{
/**
* @var string overides the parent default.
*/
public $template = "{limit}\n{pager}\n{items}\n{pager}\n{limit}";
/**
* @var array the option values for use in the drop down
*/
public $pageSizeOptions = array( '5' => '5', '10' => '10', '20' => '20', '50' => '50' );
/**
* @var CModel the model that is used to power the search.
*/
public $model;
/**
* Renders the Show X amount of items drop down.
*/
public function renderLimit()
{
if ( ! $this->model instanceof CModel )
{
return;
}
$refl = new ReflectionClass( $this->model );
if ( ! $refl->hasProperty( 'pageSize' ) )
{
return;
}
echo CHtml::openTag( 'div', array( 'class' => 'grid-limit' ) );
echo CHtml::label( 'Show:', null );
echo CHtml::activeDropDownList( $this->model, 'pageSize',
array( '5' => '5', '10' => '10', '20' => '20', '50' => '50' ), array( 'class' => 'grid-limit-field' ) );
echo CHtml::closeTag( 'div' );
}
/**
* Overides parent to add in jQuery for the changing of the drop down lists.
*/
public function registerClientScript()
{
parent::registerClientScript();
$id = $this->getId();
Yii::app()->getClientScript()->registerScript( __CLASS__ . '#' . $id . '#limit-field', <<<___JS___
$('#{$this->getId()} .grid-limit-field').live( 'change', function() { $.fn.yiiGridView.update('{$id}', { data: $(this).serialize() }); return false; } );
___JS___
, CClientScript::POS_READY );
}
}
Posted 15 August 2011 - 03:41 AM
mdomba, on 12 August 2011 - 01:01 AM, said:
Posted 15 August 2011 - 07:06 AM
Posted 15 August 2011 - 12:19 PM
Posted 26 November 2012 - 01:36 PM
Posted 12 January 2013 - 07:00 PM
Posted 01 February 2013 - 05:49 AM
Posted 01 February 2013 - 02:20 PM
class Edible extends CActiveRecord
{
public $pageSize=10;
public function rules()
{
return array(
array('name', 'required'),
array('name', 'length', 'max'=>64),
array('id, name,pageSize', 'safe', 'on'=>'search'),
);
}
public function search()
{
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('name',$this->name,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
'pagination'=>array("pageSize"=>$this->pageSize),//Declaring page size.
));
}
}
<?php echo CHtml::activeDropDownList($model,'pageSize',array(5=>5,10=>10,20=>20,50=>50,100=>100));?>
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'edible-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
//calling beforeAjaxUpdate method.
'beforeAjaxUpdate'=>'js:function(id,options)
{
var url=options.url;
url=url+"&Edible[pageSize]="+$("#Edible_pageSize").val();
options.url=url;
return true;
}',
'columns'=>array(
'id',
'name',
array(
'class'=>'CButtonColumn',
),
),
)); ?>
<?php
Yii::app()->clientScript->registerScript('test','
$("#Edible_pageSize").on("change",function(){
$("#edible-grid").yiiGridView("update",{data:{"Edible[pageSize]":$(this).val()}});
});
');