/** * Delete multiple existing AnswerList model. * For ajax request will return json object * and for non-ajax request if deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionBulkDelete() { $request = Yii::$app->request; $pks = $request->post('pks'); // Array or selected records primary keys foreach (AnswerList::findAll(json_decode($pks)) as $model) { $model->delete(); } if ($request->isAjax) { /* * Process for ajax request */ //Yii::$app->response->format = Response::FORMAT_JSON; $this->redirect(['index']); return 'Записи успешно удалены.'; //return ['forceClose'=>true,'forceReload'=>'#crud-datatable-pjax']; } else { /* * Process for non-ajax request */ return $this->redirect(['index']); } }