include partial view in CGridView or CGridDetail

Basically I’d like to include an upload link (rendered by sfancyupload extension) in view or grid. The upload link has its own view _upload.php.

I have no problem including it as partial and works as intended:


<?php $this->renderPartial('_upload',array(

        'model'=>$model,

)); ?>



How can you include a partial in views that uses CGridView and CGridDetail widgets?

bump.

For CGridView you have to define the column like this for widgets or partials:




array(

	'name'=>'addres',

	//'value'=>'Yii::app()->Controller->widget("application.extensions.widget", array("label"=>$data->address,"ajax"=>array("place/details", "id"=>$data->id, "firm_id"=>$_GET["firm_id"])));'

	'value'=>'Yii::app()->Controller->renderPartial("details",array("model"=>$data))'

		),



For CDetailView must be a little different, and I didn’t test it.

Good Luck,

Paul

Thanks for your response, Paul.

This works if I don’t pass any model into the details view. However, if I need to pass $model, I get error:

As shown in the CGridView, the model for the current row is named “$data” and it’s somehow the only way to send some data to the view. And global variables, too. The problem is that CGridView eval’s the code (sent as a string) inside it’s class without having access to the parent controller (and view) and its data. So, no variables from the current view.

Regards,

Paul

PS: you also have access to “$row”, the zero based row number. Maybe you’ll find other variables if you study the CGridView class and make some tests.

I need this enhanced in my project. It’s usefull when we have left join with more than 1 records,would it be a issue for DEV? :rolleyes:

Sorry yes.yii, I don’t understand.

Talking about widget rendering I found that the it gives the ‘htmlspecialchars’ error. I have a soft delete implemented in default scope and I solved the problem by adding ‘restore_error_handler();’ at the beginning of the function.

Regards,

Paul