Cgridview Links Inside Renderpartial

Hello.

I have a bit complicated structue here. In two words: the front page with some administrative tools inside floating div.

It’s made of preloaded empty div in main layout which gets contents via ajaxLink that sending request to a module and puts contents into this div.

The module’s view only renders some ajaxLinks to different tools: users management, group management etc. This links updates current div without page beign refreshed. Links are getting content from another views of the same module.

Module’s controller:




class IndexController extends Controller {

	public function actionIndex() {

		$this->renderPartial('index',null,false,true);

	}

        public function actionUsers() {

                $model = new Users('search');

                $this->renderPartial('users',array(

                    'model' => $model,

                ));

        }

        ...

}



I have a problem with CGridView. Links inside this widget forcing page to reload, and I need only reload div contents.

Here’s the view:




<div id="users-grid">

<?php


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

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

	'filter' => $model,

	'columns' => array(

		array(

			'name' => 'name',

			'type' => 'raw',

			'value' => 'CHtml::encode($data->name)'

		),

		array(

			'name' => 'email',

			'type' => 'raw',

			'value' => 'CHtml::link(CHtml::encode($data->email), "mailto:".CHtml::encode($data->email))',

		),

                array(

                        'class'=>'CButtonColumn',

                ),

	),

));

?>

</div>



Since I set processOutput of actionIndex of the module to true, I get no css or js with grid. That’s fine. All styles I need are stored in the layout, but may be it’s a reason for ajax that’s not works right.

So, is there a way to make paginator and other links to be ajaxLinks?

After some modifications it’s finally works as it should. Here’s the working code:

Controller of module. (I’ve renamed it from Default to Index):




class IndexController extends Controller

{

	public function actionIndex()

	{

                Yii::app()->clientscript->scriptMap['*.js'] = false;

		$this->renderPartial('index',null,false,true);

	}

        

        public function actionUsers() {

                $cs = Yii::app()->clientScript;

                $cs->reset();

                $cs->scriptMap = array(

                        'jquery.js' => false, // prevent produce jquery and styles in additional data

                        'styles.css' => false,

                        'pager.css' => false

                );

                $model =new Users('search');

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

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

                else

                        $model->unsetAttributes(); // clear table's default values


                $params =array(

                        'model'=>$model,

                );


                if(!isset($_GET['ajax'])) $this->render('users', $params);

                else  $this->renderPartial('users', $params);

        }

}



And the view:




<div id="users-grid">

<?php


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

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

	'columns' => array(

		array(

			'name' => 'FIO',

			'type' => 'raw',

			'value' => 'CHtml::encode($data->FIO)'

		),

		array(

			'name' => 'email',

			'type' => 'raw',

			'value' => 'CHtml::link(CHtml::encode($data->email), "mailto:".CHtml::encode($data->email))',

		),

	),

));

?>

</div>