Yii Framework Forum: paging - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

paging select the number of rows per page Rate Topic: -----

#1 User is offline   y_i_i 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 38
  • Joined: 26-March 12

Posted 19 June 2012 - 05:57 AM

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,, :)
0

#2 User is offline   J.J 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 126
  • Joined: 01-April 11

Posted 22 June 2012 - 10:53 AM

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,
                        ),
		));
	}

0

#3 User is offline   y_i_i 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 38
  • Joined: 26-March 12

Posted 26 June 2012 - 08:07 AM

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
0

#4 User is offline   zykapratama 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 13-January 11
  • Location:Indonesia

Posted 17 January 2013 - 02:20 AM

View Posty_i_i, on 26 June 2012 - 08:07 AM, said:

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...
0

#5 User is offline   mrkoeh 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 42
  • Joined: 31-October 12
  • Location:Indonesia

Posted 17 January 2013 - 03:27 AM

View Posty_i_i, on 26 June 2012 - 08:07 AM, said:

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


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
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users