Reputation: 371
I have view page with both detailview and gridview the grid view should be automatically filltered by detailview datas.one important thing is detail view model and gridview model are not same they should taken from different models and i didnt assign any relation so all needs to be manul. and also the view should be exported to pdf and excel view.
my view.php is
<?php $this->widget('zii.widgets.CDetailView', array(
'data'=>$model,
'attributes'=>array(
'id',
'invoice_no',
'invoice_date',
'dc_no',
'dc_date',
'client',
'total_amount',
'status',
),
)); ?>
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'invoice-transaction-grid',
'dataProvider'=>$dataProvider->search(),
'filter'=>$model,
'columns'=>array(
//'invoice_id',
//'invoice_no',
'dc_no',
'client',
/*array(
'name'=>'client',
'value'=>'Client::model()->findByPk($data->client)->Client_name',
'filter'=>CHtml::listData(Client::model()->findall(),'Client_id','Client_name'),
),*/
'project',
/*array(
'name' => 'project',
'value' => 'Project::model()->findByPk($data->project)->proj_name',
'filter'=>CHtml::listData(Project::model()->findall(),'proj_id','proj_name'),
),*/
'complexity',
/*array(
'name' => 'complexity',
'value' => 'Complexity::model()->findByPk($data->complexity)->Complexity_Name',
'filter'=>CHtml::listData(Complexity::model()->findall(),'id','Complexity_Name'),
),*/
'totalpage',
'rate_per_page',
'total_amount',
/*array(
'class'=>'CButtonColumn',
),*/
),
)); ?>
i need to display the grid automatically filtered by the detailed view data ('invoice_no',) my controller for the above view
public function actionView($id)
{
//$dataProvider=new CActiveDataProvider('InvoiceTransaction');
$dataProvider=new InvoiceTransaction('search');//this is a different model
$dataProvider->unsetAttributes(); // clear any default values
if(isset($_GET['InvoiceTransaction']))
$dataProvider->attributes=$_GET['InvoiceTransaction'];
$this->render('view',array(
'model'=>$this->loadModel($id),'dataProvider'=>$dataProvider,
));
}
how to solve my problem..anyone can give suggest
ANSWER hi i got answer for filtering questioni just added default filter value in my controller
public function actionView($id)
{
//$dataProvider=new CActiveDataProvider('InvoiceTransaction');
$model=$this->loadModel($id);
$dataProvider=new InvoiceTransaction('search');
$dataProvider->unsetAttributes(); // clear any default values
if(isset($_GET['InvoiceTransaction']))
$dataProvider->attributes=$_GET['InvoiceTransaction'];
$dataProvider->invoice_no=$model->invoice_no;/// this line only gave me answer
//$model->unsetAttributes();
if(isset($_GET['InvoiceMaster']))
$dataProvider->attributes=$_GET['InvoiceMaster'];
$this->render('view',array(
'model'=>$model,'dataProvider'=>$dataProvider,
));
}
but now struggling to export this both detailview and gridview on same file to pdf or excel.
Upvotes: 0
Views: 2969
Reputation:
PHPExcel can create Excel documents and export them to PDF. Some examples can be found here.
Upvotes: 2