I have a report table and columns report_id, reference_number
and report_name
. Some of the data has the same reference_number
. It is displayed in the gridview with view button.
What I want is when I click the view button of the specific row, the data of the row will show as well as the row that has the same reference_number
of i selected. As of now, i can display all the records with the same reference_number
but what I want is when I click the specific row, it will be shown on the top and the other details will just below it.
$gridColumns = [
['class' => 'yii\grid\SerialColumn'],
'report_id',
'reference_no',
'subject',
'doc_date',
[
'label' => 'For',
'value' => 'namefor.fullName',
],
[
'label' => 'From',
'value' => 'namefrom.fullName',
],
'drawer_id',
'user_id',
'doc_name',
[
'class' => 'yii\grid\ActionColumn',
],
[
'attribute' => '',
'format' => 'raw',
'value' => function($data)
{
return Html::a('', ['report/download', 'id' => $data->reference_no],['class' => 'fa fa-download']);
}
],
];
echo
// ExportMenu::widget([
// 'dataProvider' => $dataProvider,
// 'columns' => $gridColumns
// ]);
GridView::widget([
'dataProvider'=> $dataProvider,
'filterModel' => $searchModel,
'columns' => $gridColumns,
'responsive'=> true,
'hover'=> true,
'pjax'=> true,
'pjaxSettings'=>[
'neverTimeout'=>true,
]
]);
The controller
public function actionIndex()
{
$searchModel = new reportDetailsSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
public function actionView($id)
{
$dataProvider = new ActiveDataProvider([
'query' => reportDetails::find()
->select('reference_no, report_id')
->where(['report_id' => $id]),
'pagination' => [
'pageSize' => 10,
],
]);
return $this->render('view', [
'model' => $this->findModel($id),
'dataProvider' => $dataProvider,
]);
}