2017 © Pedro Peláez
 

yii2-extension yii2-treegrid

Extension for Yii2 Framework to work with jQuery TreeGrid

image

leandrogehlen/yii2-treegrid

Extension for Yii2 Framework to work with jQuery TreeGrid

  • Tuesday, January 16, 2018
  • by leandrogehlen
  • Repository
  • 14 Watchers
  • 33 Stars
  • 19,652 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 21 Forks
  • 2 Open issues
  • 3 Versions
  • 12 % Grown

The README.md

jQuery TreeGrid Extension for Yii 2

This is the 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, (*1)

Yii2 Latest Stable Version Total Downloads, (*2)

Installation

The preferred way to install this extension is through composer., (*3)

Either run, (*4)

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

or add, (*5)

"leandrogehlen/yii2-treegrid": "*"

to the require section of your composer.json file., (*6)

Usage

Model, (*7)


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, (*8)

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, (*9)

use leandrogehlen\treegrid\TreeGrid;

<?= TreeGrid::widget([
    'dataProvider' => $dataProvider,
    'keyColumnName' => 'id',
    'parentColumnName' => 'parent_id',
    'parentRootValue' => '0', //first parentId value
    'pluginOptions' => [
        'initialState' => 'collapsed',
    ],
    'columns' => [
        'name',
        'id',
        'parent_id',
        ['class' => 'yii\grid\ActionColumn']
    ]     
]); ?>

Adding resources

When is necessary to add other resource files, then should be used the Dependency Injection concept., (*10)

To use the saveState option it's necessary to add jquery.cookie.js., (*11)

//config/web.php

$config = [
  'id' => 'my-app',
  'components' => [
    ...
  ]
  ...
]

Yii::$container->set('leandrogehlen\treegrid\TreeGridAsset',[
    'js' => [
        'js/jquery.cookie.js',
        'js/jquery.treegrid.min.js',
    ]
]);

return $config;

The Versions

16/01 2018

dev-master

9999999-dev

Extension for Yii2 Framework to work with jQuery TreeGrid

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

yii2 tree interface treeview treegrid

30/11 2015

1.0.1

1.0.1.0

Extension for Yii2 Framework to work with jQuery TreeGrid

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

yii2 tree interface treeview treegrid

14/08 2015

1.0.0

1.0.0.0

Extension for Yii2 Framework to work with jQuery TreeGrid

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

yii2 tree interface treeview treegrid