Problem With The Pagination In Cgridview

Hello,

I’m newbie on Yii.

On view, I’ve created three tab with CJuiTabs, in one of wich I call a controller action (data), If the form hasn’t been sent, I load it through renderpartial in the view. If the form has been sent I generate the data in order to load them in a CGridView (aslo through renderpartial).

The view where the CGridView is load the form correctly. The problem is when I click on any of the pagination links because the data isn’t load on CGridView anymore. Instead of this, there are shown on the form directly. How can I solve this problem?

I paste here the code in order to show my problem clearer.

Thank you.

CJuiTabs view:




<?php

/* @var $this ZonasController */

/* @var $model Zonas */

$this->breadcrumbs=array(

        'Zonases'=>array('index'),

        $model->id,

);

?>

<?php


$this->widget('zii.widgets.jui.CJuiTabs',array(

    'id'=>'zonas_tab',

    'tabs'=>array(

   

        Yii::t('default', 'Mapa')=>array('ajax'=>Yii::app()->createUrl('zonas/mapa', array('id'=>$model->id))),

        Yii::t('default', 'Datos')=>array('ajax'=>Yii::app()->createUrl('zonas/datos', array('id'=>$model->id))),

        Yii::t('default', 'Gráficas')=>$this->renderPartial("_viewGraficas", array('model' => $model), $this),

    ),

    // additional javascript options for the tabs plugin

    'options'=>array(

        'collapsible'=>true,

    ),

));


?>



Form view:




<div class="form">


<?php $form=$this->beginWidget('CActiveForm', array(

        'id'=>'datos-search',

        'enableAjaxValidation'=>true,

        'clientOptions'=>array(

            'validateOnSubmit'=>true, 

            'validateOnChange'=>true,

        )    

));?>

    <div id="formResult"></div>

        <p class="note">Fields with <span class="required">*</span> are required.</p>

        <?php echo $form->errorSummary($model2); ?>

        <div class="row">

                <?php echo $form->labelEx($model2,Yii::t('default', 'FInicio')); ?>

                <?php 

                    $this->widget('zii.widgets.jui.CJuiDatePicker', array(

                        //'language'=>'es',

                        'model'=>$model2,

                        'attribute'=>'FInicio',

                        'options'=>array('dateFormat'=> 'yy-mm-dd'),

                        //'htmlOptions'=>array('readonly'=>true),

                    ));

                ?>

                <?php echo $form->error($model2,'FInicio');?>

        </div>

        <div class="row">

                <?php echo $form->labelEx($model2,Yii::t('default', 'FFin')); ?>

                <?php 

                    $this->widget('zii.widgets.jui.CJuiDatePicker', array(

                        //'language'=>'es',

                        'model'=>$model2,

                        'attribute'=>'FFin',

                        'options'=>array('dateFormat'=> 'yy-mm-dd'),

                        //'htmlOptions'=>array('readonly'=>false),

                    ));

                ?>

                <?php echo $form->error($model2,'FFin'); ?>

        </div>    

        <div class="row">

                <?php echo $form->labelEx($model2,'EnSal'); ?>

                <?php echo $form->dropDownList($model2,'EnSal', CHtml::listData(Ensal::model()->findAll("id_zona=$model->id"), 'id', 'nombre')); ?>

                <?php echo $form->error($model2,'EnSal'); ?>

        </div>

        <div class="row buttons">

                <?php

               echo CHtml::ajaxSubmitButton('submit',

                        Yii::app()->createUrl('/zonas/datos',array('id'=>$model->id)),

                        array(

                            'type'=>'POST', 

                            'update'=>'#content-formImeter',

                            'success'=>"function(data) {

                                            if (data.indexOf('{')==0) {

                                                var e = jQuery.parseJSON(data);

                                                jQuery('.errorSummary').empty();

                                                var list = jQuery('.errorSummary').append('<ul></ul>').find('ul');

                                                jQuery.each(e, function(key, value) {

                                                    jQuery('#'+key+'_em_').show().html(value.toString());

                                                    jQuery('#'+key).addClass('clsError');

                                                    jQuery('label[for='+key+']').addClass('clsError');

                                                    list.append('<li>'+value.toString()+'</li>');

                                                });

                                                jQuery('.errorSummary').show();

                                            }

                                            else {

                                                jQuery('.errorMessage').hide();

                                                jQuery('.errorSummary').hide();

                                                jQuery('#content-formImeter').empty();

                                                jQuery('#content-formImeter').append(data);

                                            }

                                        }"

                            ));?>

        </div>


<?php $this->endWidget(); ?>


</div><!-- form -->


<div id="content-formImeter"></div>




View of where CJuiTabs is:




<div id="zonas-grid">

<?php 

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

        'id'=>'zonas-grid',

        'dataProvider'=>$dataProvider,

        //'filter'=>$model,

        'columns'=>array(

                'HLectura',

        ),

)); 

?>

</div>




Controller action




public function actionDatos($id)

        { 

            $model = new FBuscarDatosImts();

            $model2 = $this->loadModel($id);

            if (Yii::app()->getRequest()->getIsAjaxRequest()) {

                if (isset($_POST['FBuscarDatosImts'])) {

                    $model->attributes = $_POST['FBuscarDatosImts'];

                    if ($model->validate()) {

                        // Todos los registros de una fecha en concreto

                        if (empty($_POST['FBuscarDatosImts']['FFin'])) {

                          

                              $dataProvider=new CActiveDataProvider('Datos', array(

                                    'criteria'=>array(

                                    'join'=>"INNER JOIN imeters ON (t.id_imeter = imeters.id)",

                                    'condition'=>"imeters.id_ensal = ". $_POST['FBuscarDatosImts']['EnSal']." AND t.fecha = " .$_POST['FBuscarDatosImts']['FInicio'])));

                              $this->renderPartial('_tabDatos',array('dataProvider'=>$dataProvider,'model'=>$model2), false, true);

                        }          

                        else {

                            echo "nada";

                        }

                    }

                    else { 

                        $error = CActiveForm::validate($model);

                        if ($error != '[]') {

                            echo $error;

                            Yii::app()->end();

                        }

                    }

                    Yii::app()->end();

                }

            }

            $this->renderPartial('/zonas/_FBuscarDatosImts',array('model'=>$model2,'model2'=>$model),false,true); 

        }






I can’t solve this problem, please help me. Thanks.

I have the same problem, except I am using the YiiBooster TbTabs and TbGridView.