/** * creates the JSON for the dhtmlx tree object * @param integer $id The id of the current id * @param integer $rootId The id of the shown root node * @return JSON Returns a json array, that can be parsed by dhtmlx tree component */ public function actionJsontreeview($id = NULL, $rootId = NULL) { $data = array(); if (!is_NULL($rootId) and is_null($id)) { $data = Page::rootTreeAsArray($rootId); } else { $data = Page::nodeChildren($id, true); } return Yii::$app->response->sendContentAsFile(Json::encode($data), 'tree.json', 'application/json'); exit; }