grid view buttons

I want to use gridview with update and delete buttons for the model.How can I implement it,is there any tutorial?

[edit]I found http://www.yiiframework.com/doc-2.0/yii-grid-actioncolumn.html but how can I set the right ids at querystring (to delete etc,


delete?id=1

for example)?

Just add the ActionColumn, it’ll use the row’s primary key automatically.

So at controller I write


$dataProvider = new \yii\data\SqlDataProvider([

    'sql' => 'select id,surname,code,date,active from orders order by date desc'  

            

]);

and at view


<?=  yii\grid\GridView::widget([

    'dataProvider' => $dataProvider,

    'columns' => [

       

        'code',

        [

            'attribute' => 'date',

            'format' => ['date', 'php:Y-m-d']

        ],

         [

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

            // you may configure additional properties here

        ],

    ],

]); ?>

and it does not seem to take the primary key,it begins from 0


view?id=0 

and goes on 1,2,3,4 and 18 at last record (with id 19).

What is going wrong?

You have to set the key in your data provider:

http://www.yiiframework.com/doc-2.0/yii-data-sqldataprovider.html#$key-detail