/** * Validation of source query data * * @throws InvalidConfigException */ protected function validateSourceData() { if (empty($this->query) || !$this->query instanceof ActiveQuery) { throw new InvalidConfigException("The 'query' property must be defined and must be an instance of '" . ActiveQuery::className() . "'."); } $class = isset($this->query->modelClass) ? $this->query->modelClass : null; if (empty($class) || !is_subclass_of($class, ActiveRecord::className())) { throw new InvalidConfigException("The 'query' must be implemented using 'ActiveRecord::find()' method."); } $trait = 'jaclise\\tree\\models\\TreeTrait'; if (!self::usesTrait($class, $trait)) { throw new InvalidConfigException("The model class '{$class}' for the 'query' must use the trait '{$trait}' or extend from '" . Tree::className() . "''."); } }
public function actionIndex() { $htmlData = TreeView::widget(['query' => Tree::find()->addOrderBy('root, lft'), 'headingOptions' => ['label' => '基础数据管理'], 'isAdmin' => true, 'displayValue' => 1, 'softDelete' => false]); return $this->render('index', ['htmlData' => $htmlData]); }