How to insert/edit records in Yii2 GridView, similar to ASP.Net

1.4k Views Asked by At

In ASP.Net, we can make the GridView edit/update or delete a row, and insert (using footer). Can I do something similar in Yii2, instead of creating one record at a time in a new page?

2

There are 2 best solutions below

0
On BEST ANSWER

The gridview provided by default does not allow this behavior. For this type of features you can use Extensions as Tabular From

These extension are easily configurable and free

2
On

In Yii2 GridView there is an action grid column as Shown:

<?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
        ['class' => 'yii\grid\CheckboxColumn'],

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

            'id',
            'name',
            'price',
            'image',
            'area',
            // 'address',

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

Just place the last line ['class' => 'yii\grid\ActionColumn'], in your gridview.