creocoder / yii2-nested-sets

The nested sets behavior for the Yii framework.
Other
446 stars 129 forks source link

Question: is it possible to get a node with parents before like in a breadcrumb? #117

Closed lowap closed 6 years ago

lowap commented 6 years ago

Hi,

Thank you for this extension. I have a node e.g. apple, I need to show it like: tree > fruit > apple is this possible somehow? Thx a lot!

schmunk42 commented 6 years ago

https://github.com/creocoder/yii2-nested-sets#getting-parents-of-a-node

lowap commented 6 years ago

I've found also just right now! getBreadCrumbs() http://demos.krajee.com/tree-manager#model-methods thx a lot!

the one that you say, I don't know why but it's not working for me. Something is missing or I don't know. I need to call the function in the view for a dropdown, so I guess it's planned not for this, is it?

Oh, it's not really working somehow. Parents are not correct. I have this in model:

public function getDispName() { return $this->getBreadcrumbs(null, ' > ', null); }

and then in the form:

$form->field($model, 'group_id')->dropDownList( \yii\helpers\ArrayHelper::map(app\models\Pmgroup::find()->orderBy(['root' => SORT_ASC, 'lft' => SORT_ASC])->all(), 'id', 'dispName'), [ ]

Am I doing something wrong?

Ich habe's gefunden! ->addOrderBy('root, lft') - so ist richtig!