I have a problem with editable kartik, how can I make editable kartik stored in the database? sometimes BAD REQUEST notifications appear
My Controller
public function actions()
{
return ArrayHelper::merge ( parent::actions () , [
'editable' => [
'class' => EditableColumn::className() ,
'modelClass' => AssetMasterRequest::className() ,
'forceCreate'=> false,
]
]);
}
My View
<?php
$gridColumns = [
'assetMaster.asset_name',
'request_date',
[
'class' => 'kartik\grid\EditableColumn',
'attribute' => 'requested_by',
'pageSummary' => 'Total',
'vAlign' => 'middle',
'width' => '210px',
'editableOptions' => function ($model, $key, $index) use ($ambildata) {
return [
'header' => 'Request By',
'formOptions' => ['action'=>'pru'] ,
'size' => 'md',
'afterInput' => function ($form, $widget) use ($model, $index) {
return $form->field($model, "request_notes");
}
];
}
],
[
'class' => 'kartik\grid\EditableColumn',
'attribute' => 'request_notes',
'vAlign' => 'middle',
'width' => '210px',
'editableOptions' =>[
'formOptions'=>[
'action'=>'editable'
],
]
],
'requested_by',
];?>
Please help. Have spent two days on this. Thanks!
You must return a JSON encoded response in the array format specified above with output and message values. This is important for the AJAX request to be processed and completed successfully.
Here is a grid view configuration with editable column
echo GridView::widget([
'id' => 'kv-grid-demo',
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => $gridColumns, // check the configuration for grid columns by clicking button above
'containerOptions' => ['style' => 'overflow: auto'], // only set when $responsive = false
'headerRowOptions' => ['class' => 'kartik-sheet-style'],
'filterRowOptions' => ['class' => 'kartik-sheet-style'],
'pjax' => true, // pjax is set to always true for this demo
// set your toolbar
'toolbar' => [
[
'content' =>
Html::button('<i class="fas fa-plus"></i>', [
'class' => 'btn btn-success',
'title' => Yii::t('kvgrid', 'Add Book'),
'onclick' => 'alert("This will launch the book creation form.\n\nDisabled for this demo!");'
]) . ' '.
Html::a('<i class="fas fa-redo"></i>', ['grid-demo'], [
'class' => 'btn btn-outline-secondary',
'title'=>Yii::t('kvgrid', 'Reset Grid'),
'data-pjax' => 0,
]),
'options' => ['class' => 'btn-group mr-2']
],
'{export}',
'{toggleData}',
],
'toggleDataContainer' => ['class' => 'btn-group mr-2'],
// set export properties
'export' => [
'fontAwesome' => true
],
// parameters from the demo form
'bordered' => $bordered,
'striped' => $striped,
'condensed' => $condensed,
'responsive' => $responsive,
'hover' => $hover,
'showPageSummary' => $pageSummary,
'panel' => [
'type' => GridView::TYPE_PRIMARY,
'heading' => $heading,
],
'persistResize' => false,
'toggleDataOptions' => ['minCount' => 10],
'exportConfig' => $exportConfig,
'itemLabelSingle' => 'book',
'itemLabelPlural' => 'books'
]);