public function actionList() { $cond = new CDbCriteria(); $cond->order = 'orderby asc'; $cond->with = array('resource'); $model = BasicModel::model()->findAll($cond); $rows = array(); foreach ($model as $value) { $children = array(); foreach ($value['resource'] as $val) { $children[] = array('text' => mb_convert_encoding($val->resourcename, 'UTF8', 'GBK'), 'id' => $val->resourceid, 'leaf' => TRUE); } $rows[] = array('text' => mb_convert_encoding($value->modelname, 'UTF8', 'GBK'), 'id' => $value->modelid, 'leaf' => FALSE, 'children' => $children); } echo json_encode($rows); }
/** * Returns the static model of the specified AR class. * @return AreaBlock the static model class */ public static function model($className = __CLASS__) { return parent::model($className); }