Difference between #1 and #3 of
Creating a jQueryUI Sortable CGridView

Changes

Title unchanged

Creating a jQueryUI Sortable CGridView

Category unchanged

How-tos

Yii version unchanged

Tags unchanged

sortable, cgridview, jqueryui

Content changed

I have had to do this a couple of times now so I figured I would share it with the community. I am going to keep this short because I really hope that you are familiar with [jQueryUI's Sortable](http://jqueryui.com/demos/sortable/ "jQueryUI's Sortable") class before starting this tutorial. Here are the basic steps to achieve this: 1. Make sure your database table has a 'sortOrder' field. 2. (Optional) Add the 'sortOrder' field to your Rules() function in your model 3. Add the 'sort()' functionactionSort()' method to your controller to apply the sorting via ajax
4. Add jQuery UI to your view that has the CGridView
5. Setup the jQuery UI Code to work with the CGridView in question
[...]
**Step 2:** This step is optional but recommended.  Add this line to the model who's items you are sorting.  Without this line your item's sortOrder will never be saved:

```php
array('sortOrder', 'numerical', 'integerOnly'=>true),
```
[...]
36 0
54 followers
Viewed: 52 890 times
Version: 1.1
Category: How-tos
Written by: blindMoe
Last updated by: rAWTAZ
Created on: Sep 16, 2011
Last updated: 11 years ago
Update Article

Revisions

View all history