jambtc / yii2-tree-grid-view
A Yii2 GridView extension that provides a tree-like structure with collapsible rows.
Installs: 49
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: ~2.0.0
This package is auto-updated.
Last update: 2024-12-28 10:56:07 UTC
README
TreeGridView is a Yii2 GridView extension that provides a tree-like structure with collapsible rows.
Features
- Display data in a tree structure.
- Collapsible rows for better organization of hierarchical data.
- Intuitive icons for expanding/collapsing rows.
Installation
You can install the package using Composer. Add the package to your project with the following command:
composer require jambtc/yii2-tree-grid-view "dev-main"
Usage
use jambtc\TreeGridView; use yii\data\ArrayDataProvider; // Create a data provider (example with ArrayDataProvider) $dataProvider = new ArrayDataProvider([ 'allModels' => [ ['id' => 1, 'name' => 'Root', 'depth' => 0], ['id' => 2, 'name' => 'Child 1', 'depth' => 1], // Add more data as needed ], 'key' => 'id', ]); // Display the TreeGridView widget echo TreeGridView::widget([ 'dataProvider' => $dataProvider, 'depthColumn' => 'depth', // Specify the depth column 'columns' => [ 'id', 'name', // Add more columns as needed ], ]);