ajax - Status change by clicking image button in yii2 -
i working on yii2 gridview , want change status clicking image.
here gridview code:`
['header'=>'deleted', 'format' => 'image', 'value'=>function($data) { return $data->deleteimageurl; },], ['header'=>'reports status', 'format' => 'image', 'value'=>function($data) { return $data->statusimageurl; },],`
and in model have created these functions in model view images using image path:
public function getdeleteimageurl() { return \yii::$app->request->baseurl.'/images/'.$this->is_deleted.'.png'; } public function getstatusimageurl() { return \yii::$app->request->baseurl.'/images/'.$this->reports_status.'.png'; }
now how can change status? how can add id in image column ? can use ajax if add id there.or if there other solutions please let me know.
you should use format raw
, value as:
'value'=>function($data) { return html:img($data->statusimageurl, ['data-id'=>$data->id]); },
after can use ajax data-id
Comments
Post a Comment