yiigridview controller in renderpartial

Hi .

When i use renderPartial with a view from a diferent model/controller , yiigridview uses the controller from the main view.

ex:

in casa/update


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

            'model' => $model,

            'cod_casa'=>$model->cod_casa,

        ));

and in this update view i use


  <?php echo $this->renderPartial('//reserva/adminAll', array('model' => new Reserva(),

 'cod_casa' => $model->cod_casa, 

'modelCasa' => $model,

'referer'=>'casa')); ?>

and in this view


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

	'id'=>'reserva-grid',

	'dataProvider'=>$model->searchAll($cod_casa),

    'ajaxUpdate'=>true,


	'filter'=>$model,

	'columns'=>array(

		'id',

		'n_prereserva',

		'valorSinal',

		'n_pagamento',

		'valor',

		'reservado',

		/*

		'IdReserva',

		*/

		array(

			'class'=>'CButtonColumn',

		),

	),

)); ?>

the problem is that yiigridview call casaController

thanks in advance

You can specify ‘ajaxUrl’ property to the grid in the partial view.

http://www.yiiframework.com/doc/api/1.1/CGridView#ajaxUrl-detail

Another proble if i use


'ajaxUrl' =>$this->createUrl('reserva/adminAll',array('cod_casa' => $cod_casa)),

i get url


http://localhost/index.php/reserva/adminAll/cod_casa/1?Reserva%5Bid%5D=&Reserva%5Bn_prereserva%5D=&Reserva%5BvalorSinal%5D=77&Reserva%5Bn_pagamento%5D=&Reserva%5Bvalor%5D=&Reserva%5Breservado%5D=&Reserva_page=1&ajax=reserva-grid

but need to put cod_casa in querystring

how can i do that?

Led, I’m very sorry that I have made a mistake. :(

I’m a newbie moderator and wrongly “edited” your post when I tried to “reply” to your post. Forgive me please.

Well, do you really need that?

I mean, I don’t think the URL for ajax call has much meaning to the end users.

But anyway if you want ‘code_casa’ to be in the query string, then you have to change your urlManager rules according to your needs.

Probably you have a rule like this in your current configuration:




    '<controller:\w+>/<action:\w+>/*' => '<controller>/<action>',



"/*" at the tail of the pattern is the reason why you get


"http://localhost/index.php/reserva/adminAll/cod_casa/1"

instead of


"http://localhost/index.php/reserva/adminAll?cod_casa=1"

You can try replacing the rule with




    '<controller:\w+>/<action:\w+>' => '<controller>/<action>',



But it will also affect the other urls.