paging

haloo mastaa dan suhuuu yii,

saya ngikutin cara paging disini tapi knp data nyah ga rubah waktu dropdown nyah diselect ?

tepatnyah mungkin ada yang salah disini




array(

			'class'=>'CButtonColumn',

                        'header'=>CHtml::dropDownList('pageSize',$pageSize,array(10=>10,20=>20,50=>50,100=>100),array(

                               'onchange'=>"$.fn.yiiGridView.update('file-grid',{ data:{pageSize: $(this).val() }})",

                    )),

                ),



mohon bantuan nyah, saran atau masukkan nyah sangatt dibutuhhkan, makasiii sebelumnyah, :)

Maksudnya mau menampilkan paging di CGridView gan ? Kl spt itu, saya sih biasanya menggunakan spt ini:

Letakkan pada bagian model nya gan…




public function search()

	{

		// Warning: Please modify the following code to remove attributes that

		// should not be searched.


		$criteria=new CDbCriteria;


		$criteria->compare('id',$this->id);

		...


		return new CActiveDataProvider($this, array(

			'criteria'=>$criteria,

                    

                        // set pagination

                        'pagination'=>array(

                            'pageSize'=>10,

                        ),

		));

	}



iyah ane tw yang itu gan, tp pageSIzenyah minta bisa disesuaikan keinginan, trus pas nyari.nyari dpt lah reverensi buat dropdown, pas ane ikutin muncul tanpa error tp value not change :(

mungkin masta ada sarann atau masukan yang bisa membantuuu, thx in adv ;D

coba pake ini mas bro…

letakkan ini di function pada controllernya




$criteria = new CDbCriteria(array(

                    'condition' => 'status=' . Post::STATUS_PUBLISHED,

                    'order' => 'update_time DESC',

                    'with' => 'commentCount',

                ));

        if (isset($_GET['tag']))

            $criteria->addSearchCondition('tags', $_GET['tag']);


        $dataProvider = new CActiveDataProvider('Post', array(

                    'pagination' => array(

                        'pageSize' => Yii::app()->params['postsPerPage'],

                    ),

                    'criteria' => $criteria,

                ));


        $this->render('index', array(

            'dataProvider' => $dataProvider,

        ));



trus buat file params.php di folder config, isinya




<?php


// this contains the application parameters that can be maintained via GUI

return array(

    // this is displayed in the header section

    'title' => 'zykapratama Blog',

    // this is used in error pages

    'adminEmail' => 'webmaster@example.com',

    // number of posts displayed per page

    'postsPerPage' => 3, // ini tampilan per halamannya mas bro

    // maximum number of comments that can be displayed in recent comments portlet

    'recentCommentCount' => 10,

    // maximum number of tags that can be displayed in tag cloud portlet

    'tagCloudCount' => 20,

    // whether post comments need to be approved before published

    'commentNeedApproval' => true,

    // the copyright information displayed in the footer section

    'copyrightInfo' => 'Copyright &copy; 2009 by zykapratama Blog.',

);



happy coding…

cba ini gan,

di controller :




public function actionAdmin()

	{

		$model=new TGol('search');

		$model->unsetAttributes();  // clear any default values

		if(isset($_GET['TGol']))

			$model->attributes=$_GET['TGol'];


		[b]// page size drop down changed[/b]

		if (isset($_GET['pageSize'])) {

			Yii::app()->user->setState('pageSize',(int)$_GET['pageSize']);

			unset($_GET['pageSize']);  // would interfere with pager and repetitive page size change

		}


		$this->render('admin',array(

			'model'=>$model,

		));

	}



di model :




public function search()

	{

		// Warning: Please modify the following code to remove attributes that

		// should not be searched.


		$criteria=new CDbCriteria;


		. . . .. . . .


		return new CActiveDataProvider(get_class($this),array(

			'pagination'=>array(

				'pageSize'=> Yii::app()->user->getState('pageSize',Yii::app()->params['defaultPageSize']),

			),

			'criteria'=>$criteria,

		));

	}



di view admin.php:




//letakan paling atas

$pageSize=Yii::app()->user->getState('pageSize',Yii::app()->params['defaultPageSize']);


. . . . . . .


array(

			'class'=>'CButtonColumn',

			'template'=>'{update}',

			'header'=>CHtml::dropDownList('pageSize',$pageSize,array(20=>20,50=>50,100=>100),array(

				// change 'user-grid' to the actual id of your grid!!

				'onchange'=>"$.fn.yiiGridView.update('tgol-grid',{ data:{pageSize: $(this).val() }})",

			)),

		),



pada ‘onchange’, samain dengan nama CGridViewny. . .

CMIIW