rottriges / yii2-gantt-column
为yii2网格提供的Gantt图列,适用于项目管理或其他计划
dev-master / 1.0.x-dev
2021-11-29 19:35 UTC
This package is auto-updated.
Last update: 2024-09-29 05:29:52 UTC
README
为Yii框架2.0网格提供的Gantt列小部件扩展了数据列。它可以用于项目管理或其他规划。该小部件与Bootstrap 3.x兼容。
安装
安装此扩展的首选方式是通过composer。
先决条件
在安装此扩展之前,您必须将应用程序根目录中的composer.json
文件中的minimum-stability
设置为dev
。
安装
您可以直接运行
$ php composer.phar require rottriges/yii2-gantt-column "1.0.*"
或者您可以将以下内容添加到composer.json
文件的require
部分。
"rottriges/yii2-gantt-column": "1.0.*"
用法
具有数据提供者的模型
namespace app\models; use yii\data\ArrayDataProvider; class GanttTest extends \yii\base\Model { public function getDataProvider() { $testArray = [ [ 'task' => 'Project planing', 'type' => 'primary', 'START_DATE' => '2020-10-19', 'END_DATE' => '2020-11-07' ], [ 'task' => 'Production', 'type' => 'danger', 'START_DATE' => '2020-11-15', 'END_DATE' => '2021-03-29' ], [ 'task' => 'Release', 'type' => 'success', 'START_DATE' => '2021-04-05', 'END_DATE' => '2021-04-06' ], ]; return new ArrayDataProvider([ 'allModels' => $testArray, 'pagination' => [ 'pageSize' => 0, ], ] ); } }
视图
use yii\grid\GridView; echo GridView::widget([ 'dataProvider' => $model->dataProvider, 'columns' => [ [ 'attribute' => 'gantChart' 'class' => 'rottriges\ganttcolumn\GanttColumn', 'ganttOptions' => [ // start or endDateRange can either be a static date (Y-m-d) // or an offset in weeks to the current date (-2, 0, 5, ...) // 'dateRangeStart' => '2019-10-31', // 'dateRangeEnd' => '2020-10-01', 'dateRangeStart' => -4, 'dateRangeEnd' => 28, 'startAttribute' => 'START_DATE', 'endAttribute' => 'END_DATE', // progressBarType [string | closure] possible values // primary, info, warning or danger. 'progressBarType' => function($model, $key, $index) { return $model['type']; } // progressBarColor [string | closure] // css color property // if color is set progressbar type will be overwritten 'progressBarType' => function($model, $key, $index) { return $model['type']; } ] ], ], ]);