orlac/yii2-sortable
最新稳定版本:0.0.2
Composer 安装命令:
composer require orlac/yii2-sortable
包简介
Sortable ActiveRecord for Yii 2 framework
README 文档
README
This extension for sorting ActiveRecord models.
Install
Via Composer
$ composer require orlac/yii2-sortable
Usage
Model:
use orlac\sortable\SortableBehavior; public function behaviors(){ return [ [ 'class' => SortableBehavior::className(), ], ]; } public function behaviors(){ return [ [ 'class' => SortableBehavior::className(), 'scope' => function($model){ return Model::find()->addWere('...'); } ], ]; } public function behaviors(){ return [ [ 'class' => SortableBehavior::className(), 'scope' => function($model){ return Model::find()->addWere('...'); }, 'sortColumn' => 'sort' ], ]; }
Controller
use orlac\sortable\UpAction; use orlac\sortable\DownAction; .... public function behaviors() { return [ 'verbs' => [ 'class' => VerbFilter::className(), 'actions' => [ 'delete' => ['POST'], 'up' => ['POST'], 'down' => ['POST'], ], ], ]; } public function actions(){ return [ 'up' => [ 'class' => UpAction::className(), 'modelClass' => Model::className() ], 'down' => [ 'class' => DownAction::className(), 'modelClass' => Model::className() ], ]; }
View
use orlac\sortable\ActionColumn; <?php Pjax::begin(); ?> <?= GridView::widget([ ... 'columns' => [ ... [ 'class' => ActionColumn::className(), ], [ 'class' => ActionColumn::className(), 'template' => ($dataProvider->sort->getAttributeOrder('priority')) ? '{up} {down} {update} {delete}' : '{update} {delete}', 'order' => ($dataProvider->sort->getAttributeOrder('priority') === SORT_DESC) ? SORT_DESC : SORT_ASC, ], ], ]); ?> <?php Pjax::end(); ?>
统计信息
- 总下载量: 182
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-08-29