Hello Yii friends
I am using CActiveDataProvider to create pagination for which I am using following code in ProductController
public function actionCheck()
{
$model = new Product();
if(isset($_POST) and !empty($_POST))
{
$data = $model->checkAction($_POST);
$dataProvider = new CActiveDataProvider('Product',array(
'criteria'=>$data,
));
$this->render('check',array(
'dataProvider'=>$dataProvider,
));
}
}
Where Checkaction function is in Model which is as:
public function checkAction($data)
{ $criteria=new CDbCriteria;
$criteria->order = 'category_id ASC';
$criteria->limit = 2;
if(isset($data['id'])and !empty($data['id']) )
{
$keys=$data['id'];
}
else
{
$keys='';
$criteria->compare('category_id','='.$keys);
}
if(isset($data['keywords'])and !empty($data['keywords']) )
{
$keys=$data['keywords'];
}
if (is_numeric($keys))
{
$criteria->compare('category_id','='.$keys);
}
if(!is_numeric($keys))
{
foreach(explode(',',$keys) as $key):
$criteria->addSearchCondition('keywords', $key,true,'OR');
endforeach;
}
return $criteria;
}
which return the required data…But I am having problem in pagination. If I use request method than data comes but when I again to first page it shows blanks. Anyone Out there who can help me out or had already solved this type of problem before. If you dont understand question please ask me.
Thanks in advance
Regards
Sundar