Extract both Classes to application/extensions/
CEditableGridView represents a grid view which contains editable rows and an optional 'Quickbar' which fires an action that quickly adds entries to the table.
When you assign an Column an relation-field (for example 'post.author') this Widget automatically renders an Drop-Down Field to choose between the available actions. To achieve this, the Relation-Widget is used (it is contained in the release) (since 0.2)
To make a Column editable you have to assign it to the class 'CEditableColumn'
Use it like the CGridView:
$this->widget('zii.widgets.grid.CEditableGridView', array( 'dataProvider'=>$dataProvider, 'showQuickBar'=>'true', 'quickCreateAction'=>'QuickCreate', // will be actionQuickCreate() 'columns'=>array( 'title', // display the 'title' attribute array('header' => 'editMe', 'name' => 'editable_row', 'class' => 'CEditableColumn') ));
With this Config, the column "editable_row" gets rendered with inputfields. The Table-header will be called "editMe".
You have to define a action that receives $_POST data like this:
public function actionQuickCreate() { $model=new Model; if(isset($_POST['Model'])) { $model->attributes=$_POST['Model']; if($model->save()) $this->redirect(array('admin')); //<-- assuming the Grid was used unter view admin/ } }
Note: When using the newest "filter"-technique of Yii the automatic relation resolvment fails; so be sure to comment out the 'filter' => $model, generated by the yiic crud command.
make inputs writeable by JavaScript
make Drop-Down-List filterable by a criteria (will be in 0.3 soon)
Total 12 comments
i want to display textbox in and dropdownlist in CEditableGridView , i want to update perticular record dont want to create.
anybody cna help me?
Hi!
I'd like to try the demo, but it seems the links at the top :
are broken...
Where can I see a demo? (And maybe fix those links while you're here...)
Cheers!
hi, how can i reload the gridview after quickcreate. my form have 2 models and i just would like to reload the child grid after create aand the parent still in update form.
thanks.
nadeem #3983 ran into the error: Alias "zii.widgets.grid.CEditableGridView" is invalid. This is a documentation problem. The documentation's example was:
If you followed the installation instructions and put the class file in the extensions directory, the this should be:
I instead created an editableGrid subdirectory (of the extensions directory) for the class files. This requires changing the example code to:
Now I to need to figure out to get it to save the edited cell.
I have seen a few comments on saving the edited data to the database, but don't see an answer. When I hit save on the main record, the value in the updated edited column of the grid does not save..
How do you save the data in the CEditableColumn?
_form
Controller
hello getting this error
Alias "zii.widgets.grid.CEditableGridView" is invalid. Make sure it points to an existing PHP file i extracted file under the extension folder
$this->widget('zii.widgets.grid.CEditableGridView', array( 'dataProvider'=>$dataProvider, 'showQuickBar'=>'true', 'quickCreateAction'=>'QuickCreate', // will be actionQuickCreate() 'columns'=>array( 'Source', // display the 'title' attribute array('header' => 'editMe', 'name' => 'editable_row', 'class' => 'CEditableColumn') ),));
unfortunately i do not have a project that needs a "updated" version of the CEditableGridView yet - altough i already have a lot of ideas on what could be made better.
For example, after -ing out of a column it could get green after a successfull ajax request that saved the column, yellow with a validation error message if it fails, and red if another error occurs. As soon as i need this funtionality in one of my projects i definitely will make it modular and release it under this extension.
If you want you could start something like that - any help is appreciated of course ;)
good to know that someone still looks at this extension even if it is >1 year old ;)
hi, is there any new updates on this, would appreciate the help if could post the code to update the editable rows
great work!!
Thanks
Can you explain how the QuickCreate Action Work? I dont see a submit button there to process the changes/input on editable_row.
Hi.. This is what I'm looking for, good Job. But if I want a different editable field , for examle like dropdown or check box ?
Is there any suggesstion ? or something tutorial /example ?
Thanks a lot
Stefanus
After I made some adjustments I now can update the editable fields, still need something to delete the model..
I wonder what the use of the editable fields are? They are not posted in the current implementation (v 0.2), only the QuickBar gets posted.
Leave a comment
Please login to leave your comment.