Yii 1.1: rgridview

sortable CGridView
13 followers

This extention represent sortable CGridView

RGridView

RGridViewWidget

RGridViewWidget displays a list of ordered data items in terms of a table. This widget based on CGridView widget. You can order your model drageble.

Using: ΒΆ

$this->widget('ext.RGridViewWidget.RGridViewWidget', array(
    'dataProvider'=>$dataProvider,
    'rowCssId'=>'$data->id',
    'orderUrl'=>array('order'),
    'successOrderMessage'=>'Success',
    'buttonLabel'=>'Order',
    'template' => '{summary} {items} {order}',
    'options'=>array(
        'cursor' => 'crosshair',
    ),
    'columns'=>array(
        ...
    ),
));

Options:

  • rowCssId - string a PHP expression that will be evaluated for every data row and whose result will be rendered as the css id of the data row. In this expression, the variable $row the row number (zero-based); $data the data model for the row; and $this the column object
  • orderUrl - mixed a URL or an action route that can be used to create a URL.
  • successOrderMessage - string After successfully order message
  • buttonLabel - string Label for ajax button
  • template - string the template to be used to control the layout of various sections in the view. These tokens are recognized: {summary}, {items} and {order}. They will be replaced with the summary text, the items, and the order ajax button (pager not used).
  • options - array the initial JavaScript options that should be passed to the JUI plugin.

RGridViewAction

RGridViewAction store the ordered models.

To use RGridViewAction add it in your controller:

public function actions()
{
    return array(
            'order' => array(
            'class' => 'ext.RGridView.RGridViewAction',
            'model' => 'Model',
            'orderField' => 'order',
        ),
    );
}

Sourse: https://github.com/RSol/RGridView

P.S. In future use CJuiSortable

Total 11 comments

#8238 report it
Rsol at 2012/05/21 02:55am
Y::

Sorry... My fault.

In new project I excluded short-link class Y.

New corrected extention is v.0.3.

Thank you for your comments.

#8234 report it
huanito at 2012/05/20 04:08pm
great extension! minor typo in source

This extension works well once a few characters are added: in github source lines 52 53 looks like something slipped and deleted a few characters:

Y::command()
                    ->update($orderModel->tableName(), array(

should be more like

Yii::app()->db->createCommand()->update($orderModel->tableName(), array(

This will allow saving the updates... then it works well. Nice!

#8229 report it
huanito at 2012/05/20 04:52am
in reply to #6921 cjball

2 things to check in your controller:

  1. make sure you have added 'order' to the allowed actions in accessRules; and

  2. you have set your model and order field here:

public function actions()
        {
            return array(
                    'order' => array(
                    'class' => 'ext.RGridView.RGridViewAction',
                    'model' => 'Model',// <== change to your model
                    'orderField' => 'order', // <== change to your ordering field
                ),
            );
        }

Hope that helps.

#6926 report it
Rsol at 2012/02/14 12:35am
Error in lines 50-58

Have your table primary key? I there one field or more?

Give more information: see what answer geve server (use firebug for firefox ore other browser tools for ajax discover).

My skype: slavarud

#6921 report it
CJ Ball at 2012/02/13 03:03pm
Can't save

I can't get the save button to work. Seems to have something to do with lines 50-58 in RGridViewAction.php

I keep getting an html 500 error.

Can you help? What additional information do you need?

Other than this "little" issue, I love the extension.

#6528 report it
Mohammad Shahid at 2012/01/16 11:29am
hi,

thanks, it is a very useful hint

each page of pager will be a separate table list and connected through some session value :)

#6525 report it
Rsol at 2012/01/16 11:03am
poket

hi shahidmau

create your own poket - just save data in user session and fow UI use two connected sortable

#6521 report it
Mohammad Shahid at 2012/01/16 10:25am
Thanks

hi Rsol, thanks for quick reply...

I solved point number 2 and 3 myself, i modified code in actionOrder method, but point no.1 is still pending.

#6520 report it
Rsol at 2012/01/16 09:58am
RE: Useful extension

1) i am not able to use it with pager (it is very necessary)

Yes, I known. For this perpers I create other extentions, but I can't give it in public - I creating it for other man. For draggin elements beetwin pages I use "poket". User put one or more elements in poket and it shown in each pages of greed. And elemet removed form poket when user put elements in greed.

2) i am not able to show success msg after updating the row

You shoild use successOrderMessage property for this perpes. If you need other js action (no "alert") - just in line 136 of file "RGridViewWidget.php" change it.

3) it gives js error "ansver is null" when i see in firebug

Can you give more information about this point.

#6516 report it
Mohammad Shahid at 2012/01/16 08:09am
Useful extension

hi, it is so nice, but i am facing few problems

1) i am not able to use it with pager (it is very necessary)

2) i am not able to show success msg after updating the row

3) it gives js error "ansver is null" when i see in firebug

plz solve these problems(specially point no.1) and extend usage documentations if possible

thanks for providing an useful extension...

#5715 report it
wisp at 2011/11/06 12:54pm
Thanks

I was just planning on building something like this myself, you saved me a lot of time :D

Leave a comment

Please to leave your comment.

Create extension