dimis283
(Dimis283)
1
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)?
patrickm
(Yiiframework)
2
Just add the ActionColumn, it’ll use the row’s primary key automatically.
dimis283
(Dimis283)
3
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?
patrickm
(Yiiframework)
4