This extention represent sortable CGridView
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
Thanks
I was just planning on building something like this myself, you saved me a lot of time :D
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...
RE: Useful extension
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.
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.
Can you give more information about this point.
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.
poket
hi shahidmau
create your own poket - just save data in user session and fow UI use two connected sortable
hi,
thanks, it is a very useful hint
each page of pager will be a separate table list and connected through some session value :)
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.
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
in reply to #6921 cjball
2 things to check in your controller:
make sure you have added 'order' to the allowed actions in accessRules; and
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.
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!
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.
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.