wubbleyou/yii2-ordermodel
最新稳定版本:1.0.3
Composer 安装命令:
composer require wubbleyou/yii2-ordermodel
包简介
Allows users to order records in a grid view via a custom column
关键字:
README 文档
README
Allows users to order records in a grid view via a custom column. This requires 3 minor additions:
- Attach a custom behavior to a ActiveRecord
- Attach a custom action to a Controller
- Attach a custom column to a GridView
Installation
Either run
php composer.phar require --prefer-dist wubbleyou/yii2-ordermodel "*"
or add
"wubbleyou/yii2-ordermodel": "*"
to the require section of your composer.json file.
Usage
After installing the extension the following is required.
Adding the custom behavior to a ActiveRecord:
public function behaviors()
{
return [
[
'class' => OrderBehavior::className(),
'sortField => 'sort_attribute_name',
'restrictBy' => ['parent_category_name'] //optional
],
];
}
Adding the custom column to a GridView:
public function actions()
{
return [
'order' => array(
'class' => OrderModelAction::className(),
'columns' => ['order']
),
];
}
Adding the custom column to a GridView
GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
'name',
[
'class' => OrderModelColumn::className(),
'attribute' => 'order'],
['class' => 'yii\grid\ActionColumn'],
],
]);
统计信息
- 总下载量: 10.92k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-2-Clause
- 更新时间: 2016-01-27