Pagination of

Pagination in CListView

in action





                $dataProvider = new CActiveDataProvider($modelThai, array(

                        'criteria'=>array(

                                'condition'=>'province LIKE :province',

                                'params'=>array(':province'=>"%{$_POST['province']}%"),

                        ),

                        'pagination'=>array(

                                'pageSize'=>100,

                        ),

                ));


                $this->render('result',

                                          array('dataProvider'=>$dataProvider)

                                        );



And view/result.php




<?php $this->widget('zii.widgets.CListView', array(

	'dataProvider'=>$dataProvider,

	'itemView'=>'_viewResult',


    'emptyText'=>'ไม่พบข้อมูลที่ท่านต้องการ.',

    'enablePagination'=>true,

    'summaryText'=>' รายการที่ {start} ถึง {end} จากทั้งสิ้น {count} รายการ <br/> ปัจจุบันอยู่หน้า {page} จากทั้งสิ้นจำนวน {pages} หน้า',

    'summaryCssClass'=>'summary_fcb',

    'pagerCssClass'=>'pager_fcb',

    'template'=>'{summary}<hr />{pager}{items}<hr />{pager}',



file _viewResult.php




<div class="view">


	<li><?php echo CHtml::encode($data->getAttributeLabel('postcode')); ?>:

	<?php echo CHtml::link(CHtml::encode($data->postcode), array('view', 'postID'=>$data->postID)); ?>

    <?php echo CHtml::link('แก้ไข', array('update', 'postID'=>$data->postID)); ?>

	</li>


	<b><?php echo CHtml::encode($data->getAttributeLabel('province')); ?>:</b>

	<?php echo CHtml::encode($data->province); ?>

    <?php //echo $data->province; ?>

	<br />


	<b><?php echo CHtml::encode($data->getAttributeLabel('ampur')); ?>:</b>

	<?php echo CHtml::encode($data->ampur); ?>

	<br />


	<b><?php echo CHtml::encode($data->getAttributeLabel('tumbon')); ?>:</b>

	<?php echo CHtml::encode($data->tumbon); ?>

	<br />


	<b><?php echo CHtml::encode($data->getAttributeLabel('remark')); ?>:</b>

	<?php echo CHtml::encode($data->remark); ?>

	<br />




</div>



this result (help.png).

when i click link number 2 or other. it is don’t show data of page 2.

why it is show ThaipostModel_page

ThaipostModel is class ThaipostModel extends CActiveRecord{}

thank you.

At a guess, given that on the image you uploaded, we can clearly see that the link contains the right GET parameter, then if nothing is happening when you click on it, it would seem that ajaxUpdate is being used for the pagination, so when you click on the link an ajaxUpdate event is fired instead of going to the link itself, and somewhere along the way the Ajax call is failing.

If you’re not bothered about pagination using Ajax, try adding the parameter 'ajaxUpdate- => false, into the params array for your CListView widget, which should disable ajax updating.

If you want to use Ajax, then you’ll need to try debugging with Firebug to find out where the Ajax call is failing (which might mean you have to add some console.log to the listview javascript file itself.

One possibility is a problem I had, was that I am serving proper xhtml pages with the application/xhtml+xml mime type, meaning that my pages are interpreted as XML. When using CListView on one object, part of the Ajax response that was returned contained a &nbsp; (html non-breaking space) character, which is not defined as an XML entity, so the result from my Ajax request couldn’t be injected into my page because it was not proper XML.

แก้ไขได้มั้ยครับ ผมติดเหมือนกัน ถ้าได้เเล้วมาบอกกันบ้างนะครับ :)