kotchuprik/yii2-sortable-widgets 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kotchuprik/yii2-sortable-widgets

最新稳定版本:v2.2.0

Composer 安装命令:

composer require kotchuprik/yii2-sortable-widgets

包简介

Implementation Rubaxa/Sortable for Yii2. Sortable grid view inside.

README 文档

README

Join the chat at https://gitter.im/kotchuprik/yii2-sortable-widgets

Implementation Rubaxa/Sortable for Yii2 widgets.

Supported:

  • GridView widget.

demo

Latest Stable Version Total Downloads Monthly Downloads Latest Unstable Version License

Usage

Create a new migration, change a parent to the migration class from the extension and specify the table name property:

class m140811_131705_Models_order extends \kotchuprik\sortable\migrations\Migration { protected $tableName = 'models'; }

Add the sortable behavior to your model and specify the query property:

public function behaviors() { return [ 'sortable' => [ 'class' => \kotchuprik\sortable\behaviors\Sortable::className(), 'query' => self::find(), ], ]; }

Add the sorting action to your controller and specify the query property:

public function actions() { return [ 'sorting' => [ 'class' => \kotchuprik\sortable\actions\Sorting::className(), 'query' => \vendor\namespace\Model::find(), ], ]; }

If you're using another primary key (not 'id'), you must specify it in 'pk' parameter:

public function actions() { return [ 'sorting' => [ 'class' => \kotchuprik\sortable\actions\Sorting::className(), 'query' => \vendor\namespace\Model::find(), 'pk' => 'modelField' ], ]; }

Add the column to your grid view and specify the sorting url like here:

echo \yii\grid\GridView::widget([ 'dataProvider' => $model->search(), 'rowOptions' => function ($model, $key, $index, $grid) { return ['data-sortable-id' => $model->id]; }, 'columns' => [ [ 'class' => \kotchuprik\sortable\grid\Column::className(), ], 'id', 'title', 'order', ], 'options' => [ 'data' => [ 'sortable-widget' => 1, 'sortable-url' => \yii\helpers\Url::toRoute(['sorting']), ] ], ]);

If cdn is not accessible in your country, you can use Sortable library from local dependencies:

... 'columns' => [ [ 'class' => \kotchuprik\sortable\grid\Column::className(), 'useCdn' => false ], ... ], ...

统计信息

  • 总下载量: 128k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 64
  • 点击次数: 2
  • 依赖项目数: 9
  • 推荐数: 0

GitHub 信息

  • Stars: 61
  • Watchers: 10
  • Forks: 23
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固