Closed ExpandXSoln closed 4 years ago
Got the issue :-) It was due to not specifying the value in the popover. My bad :-) Here is modified code if some one requires it
[
'class' => 'kartik\grid\EditableColumn',
'header' => 'Rescheduled Time',
'headerOptions' => ['class' => 'setWidth reschedule_time', 'style' => 'color:#3c8dbc'],
'attribute' => 'reschedule_time',
'value' => function ($data) {
return ($data->reschedule_time == 0) ? 'not set' : date('h:i A',($data->reschedule_time));
},
'contentOptions' => ['class' => 'reschedule_time'],
'editableOptions' => function ($data) {
$time= ($data->reschedule_time == 0) ? 'not set' : date('h:i A',($data->reschedule_time));
return [
'name'=>'Rescheduled Time',
'asPopover' => true,
'header' => 'Rescheduled Time',
'attribute' => 'reschedule_time',
'size'=>'xs',
'inputType' => Editable::INPUT_TIME,
'value' => $time,
'options'=>[
'options'=>['placeholder'=>'Reschedule time', 'value'=>$time],
'pluginOptions'=>[
'autoclose'=>true,
'template' => false,
'size' => 'xs',
'format' => 'h:i A',
'displayFormat' => 'h:i A',
]
]
];
}
],
I have used EditableGrid with EditableColumn for selecting Time. The Model code is given below
[ 'class' => 'kartik\grid\EditableColumn', 'header' => 'Rescheduled Time', 'headerOptions' => ['class' => 'setWidth reschedule_time', 'style' => 'color:#3c8dbc'], 'attribute' => 'reschedule_time', 'value' => function ($data) { return ($data->reschedule_time == 0) ? 'not set' : date('h:i A',($data->reschedule_time)); }, 'contentOptions' => ['class' => 'reschedule_time'], 'editableOptions' => function ($data) { $time= ($data->reschedule_time == 0) ? 'not set' : date('h:i A',($data->reschedule_time)); return [ 'name'=>'Rescheduled Time', 'asPopover' => true, 'header' => 'Rescheduled Time', 'attribute' => 'reschedule_time', 'size'=>'xs', 'inputType' => Editable::INPUT_TIME, 'value' => $time, 'options'=>[ 'options'=>['placeholder'=>'Reschedule time'], 'pluginOptions'=>[ 'autoclose'=>true, 'template' => false, 'size' => 'xs', 'format' => 'h:i A', 'displayFormat' => 'h:i A', ] ]
]; } ],
$data is the filtered data that I want to show in the table. Timestamp value for the example stored in DB against variable 'reschedule_time' is -> 1577451800 which translates to "06:33 pm: IST". The grid shows correct value as shown in below image
But when I try to edit the value, the popover shows me value always as 12:00AM, any idea from the code above on what I am doing wrong?
Thanks, Aditya