How can I print a CGridView inside a view?

Hello Yii Community!

I’m editing a custom view in order to print a PDF file using this Extension: application.extensions.MPDF53.mpdf.

but now I would like to print a CGridView but I’m getting this error:

"Object of class CGridView could not be converted to string" and of course, because I do not know how to print the CGridView object in the view… what should I do?

This is my code, I’m just putting the object like a string:




<tr class="odd">

<td> <b>Title</b> </td>

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

	'id'=>'post-grid',

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

	'filter'=>$model,

	'columns'=>array(

		'id',

		'title',

		'content',

		'status',

		'tags',

		array(

			'class'=>'CButtonColumn',

			'template' => '{view} {update} {delete} {pdf}',

			'buttons'=>array(

				'pdf' => array(

				'label'=>'Create PDF Report',

				'url'=>"CHtml::normalizeUrl(array('pdf', 'id'=>\$data->id

			))",

			'imageUrl'=>Yii::app()->request->baseUrl.'/images/pdf.png',

			'options' => array('class'=>'pdf'),

			),

			),

		),


	),

)).'</td>

</tr>

Thank you! ;D

Alright, I figured out, my problem is with the PDF Extension, because I have to send the entire String to the PDF function, like this:





<?php

$pdf = Yii::createComponent('application.extensions.MPDF53.mpdf');

$html=' bla ';  #some html


$mpdf->SetHTMLHeader($header);

$mpdf->WriteHTML($html);

$mpdf->Output('OhyeahItsaPDFfile.pdf','D');




?>



How do you guys fix a problem like this one?

I was thinking in ‘rendering’ the view in a html page 1st and then somehow get the source code (html) and send it to the PDF extension function…

What do you think?