CGridView within CJuiTabs pager

I’m trying to use a CGridView within a CJuiTabs widget, and on intial load it looks fine.

Once I click on any of the pager links within the CGridView, though, it renders without the CJuiTabs widget. (Or styling, for that matter.)

My controller code is…

Code to get data for the CGridView


	public function actionBreedingRecord()

	{

	    $horse = $this->loadModel();

	    if ($horse instanceof HorseMale) {

	        $field = 'sireId';

	        $type = 'Sire'; 

	    } else {

	        $field = 'damId';

	        $type = 'Dam';

	    }

	    $foals = new CActiveDataProvider('Horse', array(

	        'criteria'=>array(

	            'condition'=>'statusId != :unborn',

	            'params'=>array(':unborn'=>Status::UNBORN),

	            'with'=>array('pedigree'=>array(

	                'condition'=>"{$field}=:id",

	                'params'=>array(':id'=>$horse->id))),

    	        'order'=>'SUBSTRING(dob,1,4) ASC, name ASC',

    	        ),

    	        'pagination'=>array(

    	            'pageSize'=>20

    	        ),

            ));

        $this->renderPartial('_breeding', 

            array('foals' => $foals, 'type' => $type), false, true);

	}

Code to display the entire page


	public function actionView()

	{ 

		if (isset($_GET['id'])) {

            $horse = HorseService::getInstance()->getHorseInfo($_GET['id']);

		} else {

		    throw new CHttpException('Horse id is required', 404);

		}

		$tabs = $this->getTabs($horse);

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

			'model'=>$horse,

		    'tabs'=>$tabs,

		    'selectedTab'=>$this->getSelectedTab($horse, $tabs),

		));

	}

Code to display the CGridView


<?php 

$columns = array(

        array(

            'header'=>'Name',

        	'labelExpression'=>'$data->getFullName()',

            'class'=>'CLinkColumn',

            'urlExpression'=>'Yii::app()->createUrl("horse/view",array("id"=>$data->id))'),

        array(

            'header'=>'YOB',

            'name'=>'dob',

            'value'=>'substr($data->dob,0,4)'),

        array(

            'header'=>'Gender',

            'name'=>'gender',

            'value'=>'$data->getGenderText()'));

if ($type == 'Sire') {

    $columns[] = array(

        'header'=>'Dam',

    	'name'=>'pedigree.dam.name',

        'type'=> 'raw',

        'value'=>'!empty($data->pedigree->dam->name) ? $data->pedigree->dam->getUrl() : "Created"');

} else {

    $columns[] = array(

        'header'=>'Sire',

    	'name'=>'pedigree.sire.name',

        'type'=> 'raw',

        'value'=>'!empty($data->pedigree->sire->name) ? $data->pedigree->sire->getUrl() : "Created"');    

}

$columns[] = array(

    'header'=>'Status',

    'name'=>'status.name',

    'value'=>'$data->status->name');

$columns[] = array(

    'header'=>'Race Record',

    'name'=>'TrackRecord',

    'value'=>'$data->getTrackRecord()');

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

    'dataProvider'=>$foals,

    'columns'=>$columns,

    'enablePagination'=>true,

    'summaryText'=>'{start} to {end} of {count} foal(s)',

    'emptyText'=>'No Foals.',

)); ?>

What do I need to add to make the pager links act as ajax calls and only update the CGridView div (inside the CJuiTabs widget)?

Thanks!

In the documentation of CGridView is said that it can degenerate to normal get request.

This seems to be a common problem, I already read of such stuffs and I had a CGridView in a CJuiDialog and this too degenerated to normal get request.

I solved with a bad workaround (rewriting the html-code generated by CCGridView, and I used ajax pager and ajax sort).

Yii 1.1.3 works fine for me if adding an ‘id’ to the widget.




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

    'dataProvider'=>$foals,

!!  'id'=>'your id',

    'columns'=>$columns,

    'enablePagination'=>true,

    'summaryText'=>'{start} to {end} of {count} foal(s)',

    'emptyText'=>'No Foals.',

)); 



hope it helps

Thanx it helped me to!