PHPackages                             sharkom/yii2-sortable-gridview - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. sharkom/yii2-sortable-gridview

ActiveYii2-extension[Framework](/categories/framework)

sharkom/yii2-sortable-gridview
==============================

Sortable GridView for Yii2

026PHP

Since Apr 19Pushed 1y agoCompare

[ Source](https://github.com/SharKom/yii2-sortable-gridview)[ Packagist](https://packagist.org/packages/sharkom/yii2-sortable-gridview)[ RSS](/packages/sharkom-yii2-sortable-gridview/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

yii2-sortable-gridview
======================

[](#yii2-sortable-gridview)

[![Latest Stable Version](https://camo.githubusercontent.com/46bcc83a529ddcdf6e4ed6496f38134143af218c7a69a0a7a0d18e7af3ac73f5/68747470733a2f2f706f7365722e707567782e6f72672f7269636861726466616e313132362f796969322d736f727461626c652d67726964766965772f762f737461626c65)](https://packagist.org/packages/richardfan1126/yii2-sortable-gridview)[![Total Downloads](https://camo.githubusercontent.com/240bfa4679c57cf4b5587761d1dfd539a55e4dfeb8d9867a428f7b61ee1b3c7e/68747470733a2f2f706f7365722e707567782e6f72672f7269636861726466616e313132362f796969322d736f727461626c652d67726964766965772f646f776e6c6f616473)](https://packagist.org/packages/richardfan1126/yii2-sortable-gridview)[![GitHub stars](https://camo.githubusercontent.com/60761ba30af42edae41f0aab0b3338adf1935be21c257749fddc5c7e522ad317/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f7269636861726466616e313132362f796969322d736f727461626c652d67726964766965772e737667)](https://github.com/richardfan1126/yii2-sortable-gridview/stargazers)[![GitHub issues](https://camo.githubusercontent.com/c5732549f9ad010b7aacb6a80f22d71d94de1122bcc6c73bb7ac833e344ec9bc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f7269636861726466616e313132362f796969322d736f727461626c652d67726964766965772e737667)](https://github.com/richardfan1126/yii2-sortable-gridview/issues)

This is an extension of Yii2 GridView.

This extension render a sortable GridView which you can drag and drop the record items from the list, and store the order in ActiveRecord.

Getting Started
---------------

[](#getting-started)

### Installing

[](#installing)

Install with Composer:

```
composer require richardfan1126/yii2-sortable-gridview "*"

```

or

```
php composer.phar require richardfan1126/yii2-sortable-gridview "*"

```

or add

```
"richardfan1126/yii2-sortable-gridview":"*"

```

to the require section of your composer.json file.

### Setting up SortableAction

[](#setting-up-sortableaction)

In your controller, add the SortableAction into action():

```
use richardfan\sortable\SortableAction;

public function actions(){
    return [
        'sortItem' => [
            'class' => SortableAction::className(),
            'activeRecordClassName' => YourActiveRecordClass::className(),
            'orderColumn' => 'name_of_field_storing_ordering',
            'startPosition' => 1, // optional, default is 0
        ],
        // your other actions
    ];
}
```

### Setting up SortableGridView

[](#setting-up-sortablegridview)

In the view file, use SortableGridView as using the Yii default GridView

```
use richardfan\sortable\SortableGridView;
