gridview with data from another model?

hello guys, I need to create a gridview that displays data from another model filtered by a $ id , someone could help me with an example?

i have 2 models = $model1 and $model2,

in view of the $ model1 i have the detailview and I need to create a gridview that displays data from $model2

So you have in a single view you have a detailview, filled with $model1, and a gridview filled with $model2.

Are relationed $model1 and $model2 ? So when you click on a link in detailview you have to fill gridview?

Explain your need.

i have 2 models

model1Controller :




 public function actionView($id)

    {

      

        

        $dser = HdTdser::find()

        ->where(['serv_codi' => $id]);


        $dataProviderDser=  new ActiveDataProvider([

        'query' => $dser,

        'pagination' => [

            'pageSize' => 20,

        ],

        ]);


        $vipr = HdTvipr::find()

       ->where(['serv_codi' => $id]);


       $dataProviderVipr=  new ActiveDataProvider([

        'query' => $vipr,

        'pagination' => [

            'pageSize' => 20,

        ],

        ]);





        return $this->render('view', [

            'model' => $this->findModel($id),

            'dataProviderDser' =>  $dataProviderDser,

            'dataProviderVipr' =>   $dataProviderVipr,

        ]);

    }



and model1 view




<?= DetailView::widget([

        'model' => $model,

        'options' => ['class' => 'table table-striped table-bordered detail-view'],

        'attributes' => [

            'serv_codi',

            [

            'attribute'=>'tipo_codi',

            'value'=>$model->tipoCodi->tipo_nomb,

            ],

            [

            'attribute'=>'cate_codi',

            'value'=>$model->cateCodi->cate_nomb,

            ],

            [

            'attribute'=>'prio_codi',

            'value'=>$model->prioCodi->prio_nomb,

            ],

            [

            'attribute'=>'depa_codi',

            'value'=>$model->depaCodi->depa_nomb,

            ],

            [

            'attribute'=>'area_codi',

            'value'=>$model->areaCodi->area_nomb,

            ],

            'serv_nomb',

            [

            'attribute'=>'pers_auxi',

            'value'=>$model->persAuxi->Nombre,

            ],

            'serv_desc',

            'serv_fecha',

            'serv_file',

            [

            'attribute'=>'esta_codi',

            'value'=>$model->estaCodi->esta_nomb,

            ],

            'serv_mess',

        ],

    ]) ?>

</div>


<h2>  <?php echo "Respuestas"; ?> </h2>


<div class="col-md-8">

    <?= GridView::widget([

        'dataProvider' => $dataProviderDser,

      //  'filterModel' => $searchModel,

        'columns' => [

            ['class' => 'kartik\grid\SerialColumn'],


            'dser_codi',

            [

            'attribute' => 'modo_codi',//<---Variable para filtro

            'value' => 'modoCodi.modo_nomb'//<----Relación y columna que se va a mostrar

            ],

             [

            'attribute' => 'pers_auxi',//<---Variable para filtro

            'value' => 'persAuxi.Nombre'//<----Relación y columna que se va a mostrar

            ],

            [

            'attribute' => 'maqu_codi',//<---Variable para filtro

            'value' => 'maquCodi.maqu_nomb'//<----Relación y columna que se va a mostrar

            ],

             [

            'attribute' => 'esta_codi',//<---Variable para filtro

            'value' => 'estaCodi.esta_nomb'//<----Relación y columna que se va a mostrar

            ],

            // 'dser_diag',

            // 'dser_solu',

            // 'dser_file',

            // 'dser_fsol',

            // 'esta_codi',


            [  

        'class' => 'kartik\grid\ActionColumn',


        'template' => '{view}',

        'buttons' => [


            //view button

            'view' => function ($url, $model) {

                return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url, [

                            'title' => Yii::t('app', 'View'),

                            //'class'=>'btn btn-primary btn-xs',                                  

                ]);

            },


            'delete' => function ($url, $model) {

                return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [

                            'title' => Yii::t('app', 'delete'),

                            //'class'=>'btn btn-primary btn-xs',                                  

                ]);

            },

        ],


        'urlCreator' => function ($action, $model, $key, $index) {

            if ($action === 'view') {

                $url ='http://localhost/helpdesk/frontend/web/index.php/hd-tdser/view?id='.$model->dser_codi;

                return $url;

        }


   

    }


            ],

        ],


     'resizableColumns'=>true,

       


    'containerOptions' => ['style'=>'overflow: auto'], // only set when $responsive = false

    'headerRowOptions'=>['class'=>'kartik-sheet-style'],

    'pjax' => true, // pjax is set to always true for this demo

    

    

    // set your toolbar

    'toolbar' =>  [


        '{export}',

       

    ],

    // set export properties

    'export' => [

        'fontAwesome' => true

    ],

    // parameters from the demo form

    'bordered' => $bordered,

    'striped' => $striped,

    'condensed' => $condensed,

    'responsive' => $responsive,

    'hover' => $hover,

    'showPageSummary' => $pageSummary,

    'panel' => [

        //'type' => GridView::TYPE_PRIMARY,

        'heading' => $heading,

    ],

    'persistResize' => false,

    'exportConfig' => $exportConfig,


    ]); ?>

</div>



this works well , I would fail to use the delete button in gridview any idea ?