Hi everyone,
I’m having problem in setting editable column for Kartik gridview.
refer to the documentation, I already doing this.
First important thing.
$query = EmpAttendance::find()->indexBy('id');
$query->joinWith(['employee', 'createdBy']);
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
and second I setup my controller like this and i don’t understand
public function actions(){
return ArrayHelper::merge(parent::actions(), [
'editempattendance' => [ // identifier for your editable column action
'class' => \kartik\grid\EditableColumnAction::class, // action class name
'modelClass' => EmpAttendance::class, // the model for the record being edited
'outputValue' => function ($model, $attribute, $key, $index) {
return (int) $model->$attribute / 100; // return any custom output value if desired
},
'outputMessage' => function($model, $attribute, $key, $index) {
return ''; // any custom error to return after model save
},
'showModelErrors' => true, // show model validation errors after save
'errorOptions' => ['header' => 'error options'] // error summary HTML options
// 'postOnly' => true,
// 'ajaxOnly' => true,
// 'findModel' => function($id, $action) {},
// 'checkAccess' => function($action, $model) {}
]
]);
}
and the third, configure Kartik gridview editableColumn
[
'class' => 'kartik\grid\EditableColumn',
'attribute' => 'machine_time',
'format' => ['decimal', 0],
'hAlign' => 'right',
'editableOptions' => [
//'header' => 'Buy Amount',
'formOptions' => ['action' => ['/emp-attendance/editempattendance']],
'inputType' => \kartik\editable\Editable::INPUT_SPIN,
'options' => [
'pluginOptions' => ['min' => 0, 'max' => 5000]
]
],
],
and the result by going index view always pop-up the edit form for column that using editableColumn
. Am i missing something ?? please advice. thanks