PHPackages                             hjp1011/yii2-treegrid - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. hjp1011/yii2-treegrid

ActiveYii2-extension[Framework](/categories/framework)

hjp1011/yii2-treegrid
=====================

Extension for Yii2 Framework to work with jQuery TreeGrid

1.0.0(4y ago)0549BSD-3-ClauseJavaScript

Since Dec 18Pushed 4y ago1 watchersCompare

[ Source](https://github.com/hjp1011/yii2-treegrid)[ Packagist](https://packagist.org/packages/hjp1011/yii2-treegrid)[ RSS](/packages/hjp1011-yii2-treegrid/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

jQuery TreeGrid Extension for Yii 2
===================================

[](#jquery-treegrid-extension-for-yii-2)

This is the [jQuery TreeGrid](https://github.com/maxazan/jquery-treegrid) extension for Yii 2. It encapsulates TreeGrid component in terms of Yii widgets,and thus makes using TreeGrid component in Yii applications extremely easy.The project was established because the original warehouse was unstable.

[![Latest Stable Version](https://camo.githubusercontent.com/a6216417fbba9492302bed4bd53640554151ed0c3f0de83ad8d551e7ee60a175/687474703a2f2f706f7365722e707567782e6f72672f686a70313031312f796969322d74726565677269642f76)](https://packagist.org/packages/hjp1011/yii2-treegrid) [![Total Downloads](https://camo.githubusercontent.com/fa6b7c70da09f9cf3a3cc5571a1870538125656377c2c4dea169ac5b9cec6d5c/687474703a2f2f706f7365722e707567782e6f72672f686a70313031312f796969322d74726565677269642f646f776e6c6f616473)](https://packagist.org/packages/hjp1011/yii2-treegrid) [![Latest Unstable Version](https://camo.githubusercontent.com/dae9aa2a1a13ccd475f5475195c94a1146d2fbe5251bc03d542d74ca1490e471/687474703a2f2f706f7365722e707567782e6f72672f686a70313031312f796969322d74726565677269642f762f756e737461626c65)](https://packagist.org/packages/hjp1011/yii2-treegrid) [![License](https://camo.githubusercontent.com/7d6d419040ff1c850eabfab617f23b033138c5357e258ef53122b661f6e14029/687474703a2f2f706f7365722e707567782e6f72672f686a70313031312f796969322d74726565677269642f6c6963656e7365)](https://packagist.org/packages/hjp1011/yii2-treegrid) [![PHP Version Require](https://camo.githubusercontent.com/b284dec807cb25d3f48e0458e93e8b893abdebfadc89553ac3e7dfc934639018/687474703a2f2f706f7365722e707567782e6f72672f686a70313031312f796969322d74726565677269642f726571756972652f706870)](https://packagist.org/packages/hjp1011/yii2-treegrid)

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist hjp1011/yii2-treegrid "*"

```

or add

```
"hjp1011/yii2-treegrid": "*"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

**Model**

```
use yii\db\ActiveRecord;

/**
 * @property string $description
 * @property integer $parent_id
 */
class Tree extends ActiveRecord
{

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'tree';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['description'], 'required'],
            [['description'], 'string'],
            [['parent_id'], 'integer']
        ];
    }
}
```

**Controller**

```
use yii\web\Controller;
use Yii;
use yii\data\ActiveDataProvider;

class TreeController extends Controller
{

    /**
     * Lists all Tree models.
     * @return mixed
     */
    public function actionIndex()
    {
        $query = Tree::find();
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'pagination' => false
        ]);

        return $this->render('index', [
            'dataProvider' => $dataProvider
        ]);
    }
```

**View**

```
use yiiframe\treegrid\Auth;
