kartik-v / yii2-tree-manager

An advanced tree management module using nested sets for Yii 2.
http://demos.krajee.com/tree-manager
Other
150 stars 107 forks source link

Add option to select only leaves #233

Closed v4ssi404 closed 5 years ago

v4ssi404 commented 5 years ago

Scope

This pull request includes a

Changes

The following changes were made (this change is also documented in the change log):

Related Issues

If this is related to an existing ticket, include a link to it as well.

kartik-v commented 5 years ago

Go through the documentation for the Tree Node model methods.

You can achieve this by overriding the isDisabled method in your Tree node model as described here.

/**
 * Override isDisabled method if you need as shown in the  
 * example below. You can override similarly other methods
 * like isActive, isMovable etc.
 */
public function isDisabled()
{
    return $this->children()->count() > 0; // this will disable parent selection
}