Printing a CgridView

I’m fairly new to yii,

but is there anyway to either print the content of a CGridView or export the contents to pdf by clicking a button or something like that?

Thanks

Hi,

you can use fpdf.

Good luck.

are there any tutorials or walkthroughs on how to implement fpdf in the gridview?

Here

Thanks but these are tutorials on howto use fpdf in general, i don’t really have a clue on how to implement this into my cGridview After a user has specified some filters.

Assume that the user has applied a filter, and has received several pages in cgridview, is what you want to export all pages or only the current page?

The best idea is to use the same code of the admin.php, and modifying as follows:





	public function actionIndex()

	{

		$model=new Model('search');

		$model->unsetAttributes();  // clear any default values

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

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

                if (/*pdf, can be a check on the post value of the pdf button*/)

                {

                     $dataProvider= $model->search();

                     $dataProvider->pagination= false; // for retrive all modules

                     $data = $dataProvider->data()

                     foreach ($data as $model)

                     {

                        /*good luck with fpdf!!*/

                     }

                 }


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

			'model'=>$model,

		));

	}



$data = $dataProvider->data(); ??

$data = $dataProvider->data

or

$data = $dataProvider->getData()

/Tommy

$data= $dataProvider->getData() should work fine!

A pratical example with fpdf will be usefull

yes, that would be nice