vendredi 28 juillet 2017

how to add relational attributes to gridview yii2?

i have a new question yii2. how to show relational values from other tables in gridview in views/viewname/index and also add a button to that for confirm?

thank you

<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel app\models\LaptopSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Laptops';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="laptop-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a('Create Laptop', ['create'], ['class' => 'btn btn-success']) ?>
    </p>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            'id',
            'network',
            'technology',
            'sup_id',
            'speaker',
            // 'optical_drive',
            // 'webcam',
            // 'touchpad',
            // 'card_reader',
            // 'ethernet',
            // 'vga',
            // 'hdmi',
            // 'usb3_ports',
            // 'usb2_ports',
            // 'usb_type_c',
            // 'thunderbolt_ports',
            // 'serial_ports',

            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>
</div>

how to add here new attributes and also add a button?




Aucun commentaire:

Enregistrer un commentaire