Setup 1 – View
Put the following code inside gridview:
[
'class'=>'kartik\grid\EditableColumn',
'attribute' => 'nilai_tugas',
'value' => function ($model)
{
return $model->nilai_tugas;
},
'editableOptions'=> function ($model, $key, $index) {
return [
'header'=>'Name',
'size'=>'md',
'formOptions'=>['action' => ['krs-detail/editNilai']],
'inputType'=>\kartik\editable\Editable::INPUT_TEXT,
];
}
],
Setup 2 – Controller
Put the following code into controller file:
use kartik\grid\EditableColumnAction;
use yii\helpers\ArrayHelper;
use backend\models\KrsDetail;
and then create function:
public function actions()
{
return ArrayHelper::merge(parent::actions(), [
'editNilai' => [ // identifier for your editable action
'class' => EditableColumnAction::className(), // action class name
'modelClass' => KrsDetail::className(), // the update model class
]
]);
}
Below is the result of editable Gridview:
Where is the KrsDetail class, this does not exist in kartik plugin
KrsDetail.php is inside model folder.
You must change it to your model file.