I have a custom dropdown pagination in my project and using CListView to display the items, but it's not working correctly. Whatever the number that I select in the dropdownlist, or the page number, the content of the list is empty. I can see that the summary number is changed and correctly shown, but the list is not shown. What I am missing?
Below is the model - candidateSearch() code:
public function candidateSearch()
{
$criteria = new CDbCriteria;
$criteria->compare('can_id',$this->can_id);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
'sort'=>array(
'defaultOrder'=>'name ASC',
),
'pagination'=>array(
'pageSize'=> Yii::app()->user->getState('pageSize', Yii::app()->params['defaultPageSize']),
),
));
}
Below is the controller code:
public function actionIndex()
{
if (isset($_GET['pageSize']))
{
Yii::app()->user->setState('pageSize',(int)$_GET['pageSize']);
unset($_GET['pageSize']);
}
$model = new JbMeetGreet('candidateSearch');
$model->unsetAttributes(); // clear any default values
$model->can_id = Yii::app()->user->id;
$model->created_by = Yii::app()->user->id;
$model->created_by_lvl = Yii::app()->user->user_level;
//search function
if(isset($_POST['JbMeetGreet']))
{
$model->attributes = $_POST['JbMeetGreet'];
}
$this->render('index', array('model'=>$model));
}
Below is the index page code:
$pageSize = Yii::app()->user->getState('pageSize',Yii::app()->params['defaultPageSize']);
echo CHtml::dropDownList('pageSize',$pageSize,array(5=>5,10=>10,15=>15,20=>20,25=>25,30=>30),
array('onchange'=>"$.fn.yiiListView.update('meet-greet-grid',{ data:{pageSize: $(this).val() }})",
'empty'=>'-- Select Page Range --','style'=>'width:100%;'));
$this->widget('zii.widgets.CListView',array(
'id'=>'meet-greet-grid',
'dataProvider'=>$model->candidateSearch(),
'itemView'=>'_profile_list',
'template'=>'{summary}{pager}{items}',
'summaryText'=>'Result {start} - {end} of {count} results',
});
I managed to solve it. I have animation in my item view page. Deleted the animation code, and data in the subsequent pages are displayed. Thank you.