Paginator disappears

Hello gurus! Please help!

I got following problem:

There is a table in a database. There is an according model. Need to display data within CGridView applying BETWEEN filter date.

View:


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

        'id'=>'statistic-grid',

        'dataProvider'=>$model->search($startDate, $dueDate),

        'selectableRows'=>0,

        'columns'=>array(

                array(

                        'name'=>'date',

                        'header'=>'Date',

                ),

                array(

                        'name'=>'line',

                        'header'=>'Line',

                ),

                array(

                        'name'=>'callerid',

                        'header'=>'Caller ID',

                ),

                /*array(

                        'name'=>'typename',

                        'header'=>'Type'

                ),*/

                array(

                        'name'=>'result',

                        'header'=>'Result',

                ),

        ),

)); ?>



The variables $startDate & $dueDate are passed to view by the controller.

Action:


public function actionIndex(){

                $weekDay = 1;

                $startDate = '';

                $dueDate = '';

                

                if(isset($_POST['btnRun']))

                {

                        $weekDay = $_POST['weekDay'];

                        $startDate = $_POST['startDate'];

                        $dueDate = $_POST['dueDate'];

                }

                $periodDates = $this->getPeriodDates($weekDay, $startDate, $dueDate);

                

                $model=new SmsCdr('search');

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

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

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

                

                $search = SmsCdr::model()->search($periodDates['startDate'], 

                        $periodDates['dueDate']);

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

                                'model'=>$model, 

                                'dataProvider'=>$search, 

                                'startDate'=>$periodDates['startDate'],

                                'dueDate'=>$periodDates['dueDate'],

                                'weekDay'=>$weekDay,

                ));



Search method:


public function search($startDate, $dueDate, $userid = null)

        {

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

                // should not be searched.

                $criteria=new CDbCriteria;


                $criteria->compare('date',$this->date,true);

                $criteria->compare('line',$this->line,true);

                $criteria->compare('callerid',$this->callerid,true);

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

                $criteria->compare('result',$this->result,true);

                $criteria->condition = "date BETWEEN $startDate AND $dueDate";


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

                        'criteria'=>$criteria,

                        'pagination'=>array(

                                'pageSize'=>3,

                        )

                ));

Problem:

The BETWEEN date filter works fine. Everything is fine. But after clicking next button (any button) of paginator it displays "No results found". And paginator disappears.

When BETWEEN date filter is disabled everything is fine.

Please help me! How can i filter rows in correct way? ???

Thanks…

When the user hit a link button in a CGridView pager, the corresponding action is called using a "get" method. So, your $startDate and $dueDate will be reset to empty strings each time the pager button is hit. This might be the cause of the problem, I guess.