public function menuWidget($view = 'node', $attributes = array(), $return = false) { $items = $this->childrenTree($attributes); $behavior = $this; $widget = new ARTreeMenuWidget(compact('view', 'items', 'behavior'), $return); return $widget->run(); }
/** * Generates jstree menu from owner children. * @param array $data data for widget * @param bool|string $callback $this method name for data processing * - define it for variable options and bind functions attaching. * @return Widget menu widget */ public function menuWidget($data = [], $callback = false) { $data = array_merge(['items' => [$this->owner], 'behavior' => $this, 'view' => 'node'], $data); if ($callback) { $data = $this->{$callback}($data); } $widget = new ARTreeMenuWidget($data); return $widget->run(); }
public function getMenu() { $moduleName = AbstractModel::moduleName(static::className()); $model = $this->findModel(); $uniqueKey = 0; $items = $model::find()->orderBy(['lft' => SORT_ASC])->asArray()->all(); foreach ($items as &$item) { $uniqueKey++; $nodeId = $uniqueKey . '-id-' . $item['id']; $item['nodeAttributes'] = ['id' => $nodeId, 'text' => $item['name'], 'type' => 'folder', 'active' => \Yii::$app->request->get('id') == $item['id'], 'a_attr' => ['data-id' => $nodeId, 'href' => ["/{$moduleName}/category/update", 'id' => $item['id']]]]; } $treeWidget = new ARTreeMenuWidget(['items' => $items, 'view' => 'nested']); return $treeWidget->run(); }
public function run() { $treeWidget = new ARTreeMenuWidget(['items' => $this->generateItems(), 'view' => 'nested']); return $treeWidget->run(); }